🔨 added user-defined exception 311

This commit is contained in:
Niels Lohmann 2017-03-05 22:31:08 +01:00
parent 9e560ca40c
commit 6751d650be
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
3 changed files with 9 additions and 6 deletions

View file

@ -1137,6 +1137,7 @@ class basic_json
json.exception.[type_error](@ref type_error).308 | "cannot use push_back() with string" | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).309 | "cannot use insert() with" | The @ref insert() member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).310 | "cannot use swap() with number" | The @ref swap() member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).311 | "cannot use emplace_back() with string" | The @ref emplace_back() member function can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).313 | "invalid value to unflatten" | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
json.exception.[type_error](@ref type_error).314 | "only objects can be unflattened" | The @ref unflatten function only works for an object whose keys are JSON Pointers.
json.exception.[type_error](@ref type_error).315 | "values in object must be primitive" | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
@ -5559,7 +5560,7 @@ class basic_json
@param[in] args arguments to forward to a constructor of @ref basic_json
@tparam Args compatible types to create a @ref basic_json object
@throw std::domain_error when called on a type other than JSON array or
@throw type_error.311 when called on a type other than JSON array or
null; example: `"cannot use emplace_back() with number"`
@complexity Amortized constant.
@ -5576,7 +5577,7 @@ class basic_json
// emplace_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use emplace_back() with " + type_name()));
JSON_THROW(type_error(311, "cannot use emplace_back() with " + type_name()));
}
// transform null object into an array

View file

@ -1137,6 +1137,7 @@ class basic_json
json.exception.[type_error](@ref type_error).308 | "cannot use push_back() with string" | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).309 | "cannot use insert() with" | The @ref insert() member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).310 | "cannot use swap() with number" | The @ref swap() member functions can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).311 | "cannot use emplace_back() with string" | The @ref emplace_back() member function can only be executed for certain JSON types.
json.exception.[type_error](@ref type_error).313 | "invalid value to unflatten" | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
json.exception.[type_error](@ref type_error).314 | "only objects can be unflattened" | The @ref unflatten function only works for an object whose keys are JSON Pointers.
json.exception.[type_error](@ref type_error).315 | "values in object must be primitive" | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
@ -5559,7 +5560,7 @@ class basic_json
@param[in] args arguments to forward to a constructor of @ref basic_json
@tparam Args compatible types to create a @ref basic_json object
@throw std::domain_error when called on a type other than JSON array or
@throw type_error.311 when called on a type other than JSON array or
null; example: `"cannot use emplace_back() with number"`
@complexity Amortized constant.
@ -5576,7 +5577,7 @@ class basic_json
// emplace_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use emplace_back() with " + type_name()));
JSON_THROW(type_error(311, "cannot use emplace_back() with " + type_name()));
}
// transform null object into an array

View file

@ -291,8 +291,9 @@ TEST_CASE("modifiers")
SECTION("other type")
{
json j = 1;
CHECK_THROWS_AS(j.emplace_back("Hello"), std::domain_error);
CHECK_THROWS_WITH(j.emplace_back("Hello"), "cannot use emplace_back() with number");
CHECK_THROWS_AS(j.emplace_back("Hello"), json::type_error);
CHECK_THROWS_WITH(j.emplace_back("Hello"),
"[json.exception.type_error.311] cannot use emplace_back() with number");
}
}