boostorg / property_tree

Boost.org property_tree module
http://boost.org/libs/property_tree
55 stars 92 forks source link

Error handing of JSON parsing not expresive #45

Open JVApen opened 4 years ago

JVApen commented 4 years ago

The error handling of parsing JSON is not expressive enough in order to solve related problems.

Looking at https://www.boost.org/doc/libs/1_59_0/boost/property_tree/detail/json_parser/parser.hpp void parse_escape(), we fail the function with parse_error("invalid escape sequence");

Unfortunately, if all your JSON is on a single line, this tells you that there is a problem on line 1. To make this message more usable, it would make sense to not only store the line number, though also the column number, so we can check which character is incorrectly escaped. In an ideal world, the exception would even contain that character.

JVApen commented 4 years ago

This remark actually holds for all of the parse errors, as we also encountered already the same error with following message: expected value