diff --git a/src/json.hpp b/src/json.hpp index 54528175..3de94bce 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -11974,7 +11974,7 @@ basic_json_parser_74: { if (is_root()) { - JSON_THROW(std::domain_error("JSON pointer has no parent")); + JSON_THROW(out_of_range(405, "JSON pointer has no parent")); } auto last = reference_tokens.back(); @@ -11992,7 +11992,7 @@ basic_json_parser_74: { if (is_root()) { - JSON_THROW(std::domain_error("JSON pointer has no parent")); + JSON_THROW(out_of_range(405, "JSON pointer has no parent")); } json_pointer result = *this; @@ -12083,7 +12083,7 @@ basic_json_parser_74: @complexity Linear in the length of the JSON pointer. - @throw std::out_of_range if the JSON pointer can not be resolved + @throw out_of_range.404 if the JSON pointer can not be resolved @throw parse_error.106 if an array index begins with '0' @throw std::invalid_argument if an array index was not a number */ @@ -12153,7 +12153,7 @@ basic_json_parser_74: default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -12204,7 +12204,7 @@ basic_json_parser_74: default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -12263,7 +12263,7 @@ basic_json_parser_74: default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -12314,7 +12314,7 @@ basic_json_parser_74: default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 2bbff0fb..b47a48cf 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -11007,7 +11007,7 @@ class basic_json { if (is_root()) { - JSON_THROW(std::domain_error("JSON pointer has no parent")); + JSON_THROW(out_of_range(405, "JSON pointer has no parent")); } auto last = reference_tokens.back(); @@ -11025,7 +11025,7 @@ class basic_json { if (is_root()) { - JSON_THROW(std::domain_error("JSON pointer has no parent")); + JSON_THROW(out_of_range(405, "JSON pointer has no parent")); } json_pointer result = *this; @@ -11116,7 +11116,7 @@ class basic_json @complexity Linear in the length of the JSON pointer. - @throw std::out_of_range if the JSON pointer can not be resolved + @throw out_of_range.404 if the JSON pointer can not be resolved @throw parse_error.106 if an array index begins with '0' @throw std::invalid_argument if an array index was not a number */ @@ -11186,7 +11186,7 @@ class basic_json default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -11237,7 +11237,7 @@ class basic_json default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -11296,7 +11296,7 @@ class basic_json default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } @@ -11347,7 +11347,7 @@ class basic_json default: { - JSON_THROW(std::out_of_range("unresolved reference token '" + reference_token + "'")); + JSON_THROW(out_of_range(404, "unresolved reference token '" + reference_token + "'")); } } } diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index 9c07aae6..c021450b 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -791,8 +791,9 @@ TEST_CASE("JSON patch") { json j = "string"; json patch = {{{"op", "remove"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), std::domain_error); - CHECK_THROWS_WITH(j.patch(patch), "JSON pointer has no parent"); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_WITH(j.patch(patch), + "[json.exception.out_of_range.405] JSON pointer has no parent"); } } diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index c12a56ad..a6f811eb 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -49,10 +49,12 @@ TEST_CASE("JSON pointers") "[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'"); json::json_pointer p; - CHECK_THROWS_AS(p.top(), std::domain_error); - CHECK_THROWS_WITH(p.top(), "JSON pointer has no parent"); - CHECK_THROWS_AS(p.pop_back(), std::domain_error); - CHECK_THROWS_WITH(p.pop_back(), "JSON pointer has no parent"); + CHECK_THROWS_AS(p.top(), json::out_of_range); + CHECK_THROWS_WITH(p.top(), + "[json.exception.out_of_range.405] JSON pointer has no parent"); + CHECK_THROWS_AS(p.pop_back(), json::out_of_range); + CHECK_THROWS_WITH(p.pop_back(), + "[json.exception.out_of_range.405] JSON pointer has no parent"); } SECTION("examples from RFC 6901") @@ -124,10 +126,12 @@ TEST_CASE("JSON pointers") // unresolved access json j_primitive = 1; - CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], std::out_of_range); - CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], "unresolved reference token 'foo'"); - CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), std::out_of_range); - CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), "unresolved reference token 'foo'"); + CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range); + CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], + "[json.exception.out_of_range.404] unresolved reference token 'foo'"); + CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range); + CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), + "[json.exception.out_of_range.404] unresolved reference token 'foo'"); } SECTION("const access") @@ -191,10 +195,12 @@ TEST_CASE("JSON pointers") // unresolved access const json j_primitive = 1; - CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], std::out_of_range); - CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], "unresolved reference token 'foo'"); - CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), std::out_of_range); - CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), "unresolved reference token 'foo'"); + CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range); + CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], + "[json.exception.out_of_range.404] unresolved reference token 'foo'"); + CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range); + CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), + "[json.exception.out_of_range.404] unresolved reference token 'foo'"); } SECTION("user-defined string literal")