mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
improve error message for empty value
This commit is contained in:
@@ -954,11 +954,25 @@ parse_key_value_pair(location<Container>& loc)
|
|||||||
return err(std::move(msg));
|
return err(std::move(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto after_kvsp = loc.iter(); // err msg
|
||||||
auto val = parse_value(loc);
|
auto val = parse_value(loc);
|
||||||
if(!val)
|
if(!val)
|
||||||
{
|
{
|
||||||
|
std::string msg;
|
||||||
|
loc.iter() = after_kvsp;
|
||||||
|
if(sequence<maybe<lex_ws>, maybe<lex_comment>, lex_newline>::invoke(loc))
|
||||||
|
{
|
||||||
|
loc.iter() = after_kvsp;
|
||||||
|
msg = format_underline("[error] toml::parse_key_value_pair: "
|
||||||
|
"missing value after key-value separator '='", loc,
|
||||||
|
"expected value, but got nothing");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg = val.unwrap_err();
|
||||||
|
}
|
||||||
loc.iter() = first;
|
loc.iter() = first;
|
||||||
return err(val.unwrap_err());
|
return err(msg);
|
||||||
}
|
}
|
||||||
return ok(std::make_pair(std::move(key.unwrap()), std::move(val.unwrap())));
|
return ok(std::make_pair(std::move(key.unwrap()), std::move(val.unwrap())));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user