diff --git a/src/json.hpp b/src/json.hpp index 4a422209..4753b032 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -5655,7 +5655,7 @@ class basic_json @param[in] val element to insert @return iterator pointing to the inserted @a val. - @throw std::domain_error if called on JSON values other than arrays; + @throw type_error.309 if called on JSON values other than arrays; example: `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5684,7 +5684,7 @@ class basic_json return result; } - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } /*! @@ -5708,8 +5708,8 @@ class basic_json @return iterator pointing to the first element inserted, or @a pos if `cnt==0` - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5737,7 +5737,7 @@ class basic_json return result; } - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } /*! @@ -5750,8 +5750,8 @@ class basic_json @param[in] first begin of the range of elements to insert @param[in] last end of the range of elements to insert - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @throw invalid_iterator.210 if @a first and @a last do not belong to the @@ -5775,7 +5775,7 @@ class basic_json // insert only works for arrays if (not is_array()) { - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } // check if iterator pos fits to this JSON value @@ -5813,8 +5813,8 @@ class basic_json the end() iterator @param[in] ilist initializer list to insert the values from - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5833,7 +5833,7 @@ class basic_json // insert only works for arrays if (not is_array()) { - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } // check if iterator pos fits to this JSON value diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 69fef976..8f12b9e2 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -5655,7 +5655,7 @@ class basic_json @param[in] val element to insert @return iterator pointing to the inserted @a val. - @throw std::domain_error if called on JSON values other than arrays; + @throw type_error.309 if called on JSON values other than arrays; example: `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5684,7 +5684,7 @@ class basic_json return result; } - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } /*! @@ -5708,8 +5708,8 @@ class basic_json @return iterator pointing to the first element inserted, or @a pos if `cnt==0` - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5737,7 +5737,7 @@ class basic_json return result; } - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } /*! @@ -5750,8 +5750,8 @@ class basic_json @param[in] first begin of the range of elements to insert @param[in] last end of the range of elements to insert - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @throw invalid_iterator.210 if @a first and @a last do not belong to the @@ -5775,7 +5775,7 @@ class basic_json // insert only works for arrays if (not is_array()) { - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } // check if iterator pos fits to this JSON value @@ -5813,8 +5813,8 @@ class basic_json the end() iterator @param[in] ilist initializer list to insert the values from - @throw std::domain_error if called on JSON values other than arrays; - example: `"cannot use insert() with string"` + @throw type_error.309 if called on JSON values other than arrays; example: + `"cannot use insert() with string"` @throw invalid_iterator.202 if @a pos is not an iterator of *this; example: `"iterator does not fit current value"` @@ -5833,7 +5833,7 @@ class basic_json // insert only works for arrays if (not is_array()) { - JSON_THROW(std::domain_error("cannot use insert() with " + type_name())); + JSON_THROW(type_error(309, "cannot use insert() with " + type_name())); } // check if iterator pos fits to this JSON value diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index dc84a930..029dc996 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -686,20 +686,20 @@ TEST_CASE("modifiers") // call insert on a non-array type json j_nonarray = 3; json j_yet_another_array = {"first", "second"}; - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), std::domain_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), std::domain_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), std::domain_error); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), json::type_error); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), json::type_error); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), json::type_error); CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(), - j_yet_another_array.end()), std::domain_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), std::domain_error); + j_yet_another_array.end()), json::type_error); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), json::type_error); - CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10), "cannot use insert() with number"); - CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), j_value), "cannot use insert() with number"); - CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10, 11), "cannot use insert() with number"); + CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10), "[json.exception.type_error.309] cannot use insert() with number"); + CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), j_value), "[json.exception.type_error.309] cannot use insert() with number"); + CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10, 11), "[json.exception.type_error.309] cannot use insert() with number"); CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(), - j_yet_another_array.end()), "cannot use insert() with number"); + j_yet_another_array.end()), "[json.exception.type_error.309] cannot use insert() with number"); CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), - "cannot use insert() with number"); + "[json.exception.type_error.309] cannot use insert() with number"); } }