1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-22 15:21:52 +03:00

🔨 started with user-defined exceptions #301 #244

Added class hierarchy for user-defined exceptions (#244). Integrated
parse exceptions 101-103. Parse exceptions include the byte count of
the last read character to locate the position of the error (#301).
This commit is contained in:
Niels Lohmann
2017-03-01 21:28:44 +01:00
parent 7b8fd864e2
commit c085e3bac2
9 changed files with 650 additions and 252 deletions

View File

@ -579,8 +579,9 @@ TEST_CASE("regression tests")
// ss is not at EOF; this yielded an error before the fix
// (threw basic_string::append). No, it should just throw
// a parse error because of the EOF.
CHECK_THROWS_AS(j << ss, std::invalid_argument);
CHECK_THROWS_WITH(j << ss, "parse error - unexpected end of input");
CHECK_THROWS_AS(j << ss, json::parse_error);
CHECK_THROWS_WITH(j << ss,
"[json.exception.parse_error.101] parse error at 1: parse error - unexpected end of input");
}
SECTION("issue #389 - Integer-overflow (OSS-Fuzz issue 267)")
@ -778,7 +779,7 @@ TEST_CASE("regression tests")
SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)")
{
std::vector<uint8_t> vec = {'-', '0', '1', '2', '2', '7', '4'};
CHECK_THROWS_AS(json::parse(vec), std::invalid_argument);
CHECK_THROWS_AS(json::parse(vec), json::parse_error);
}
SECTION("issue #454 - doubles are printed as integers")