mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
Merge pull request #58 from ToruNiina/improve-err-msg-literal
Improve error message from toml literal
This commit is contained in:
@@ -73,6 +73,9 @@ inline ::toml::value operator""_toml(const char* str, std::size_t len)
|
||||
if(auto data = ::toml::detail::parse_toml_file(loc))
|
||||
{
|
||||
loc.reset(loc.begin()); // rollback to the top of the literal
|
||||
// skip needless characters for error message
|
||||
skip_line::invoke(loc); // skip the first several needless lines
|
||||
skip_ws::invoke(loc); // skip the first several needless whitespaces
|
||||
return ::toml::value(std::move(data.unwrap()),
|
||||
::toml::detail::region<std::vector<char>>(std::move(loc)));
|
||||
}
|
||||
|
||||
@@ -343,7 +343,8 @@ inline std::string format_underline(const std::string& message,
|
||||
{
|
||||
// invalid
|
||||
// ~~~~~~~
|
||||
retval << make_string(reg->size(), '~');
|
||||
const auto underline_len = std::min(reg->size(), reg->line().size());
|
||||
retval << make_string(underline_len, '~');
|
||||
}
|
||||
|
||||
retval << ' ';
|
||||
|
||||
Reference in New Issue
Block a user