Skip to content

Commit

Permalink
improve error message for empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
ToruNiina committed Dec 13, 2018
1 parent e86777d commit 57de57a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion toml/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,25 @@ parse_key_value_pair(location<Container>& loc)
return err(std::move(msg));
}

const auto after_kvsp = loc.iter(); // err msg
auto val = parse_value(loc);
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;
return err(val.unwrap_err());
return err(msg);
}
return ok(std::make_pair(std::move(key.unwrap()), std::move(val.unwrap())));
}
Expand Down

0 comments on commit 57de57a

Please sign in to comment.