🔨 added user-defined exceptions 308

parent 2a9393af
......@@ -5374,7 +5374,7 @@ class basic_json
@param[in] val the value to add to the JSON array
@throw std::domain_error when called on a type other than JSON array or
@throw type_error.308 when called on a type other than JSON array or
null; example: `"cannot use push_back() with number"`
@complexity Amortized constant.
......@@ -5390,7 +5390,7 @@ class basic_json
// push_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an array
......@@ -5426,7 +5426,7 @@ class basic_json
// push_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an array
......@@ -5460,7 +5460,7 @@ class basic_json
@param[in] val the value to add to the JSON object
@throw std::domain_error when called on a type other than JSON object or
@throw type_error.308 when called on a type other than JSON object or
null; example: `"cannot use push_back() with number"`
@complexity Logarithmic in the size of the container, O(log(`size()`)).
......@@ -5476,7 +5476,7 @@ class basic_json
// push_back only works for null objects or objects
if (not(is_null() or is_object()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an object
......
......@@ -5374,7 +5374,7 @@ class basic_json
@param[in] val the value to add to the JSON array
@throw std::domain_error when called on a type other than JSON array or
@throw type_error.308 when called on a type other than JSON array or
null; example: `"cannot use push_back() with number"`
@complexity Amortized constant.
......@@ -5390,7 +5390,7 @@ class basic_json
// push_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an array
......@@ -5426,7 +5426,7 @@ class basic_json
// push_back only works for null objects or arrays
if (not(is_null() or is_array()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an array
......@@ -5460,7 +5460,7 @@ class basic_json
@param[in] val the value to add to the JSON object
@throw std::domain_error when called on a type other than JSON object or
@throw type_error.308 when called on a type other than JSON object or
null; example: `"cannot use push_back() with number"`
@complexity Logarithmic in the size of the container, O(log(`size()`)).
......@@ -5476,7 +5476,7 @@ class basic_json
// push_back only works for null objects or objects
if (not(is_null() or is_object()))
{
JSON_THROW(std::domain_error("cannot use push_back() with " + type_name()));
JSON_THROW(type_error(308, "cannot use push_back() with " + type_name()));
}
// transform null object into an object
......
......@@ -152,8 +152,8 @@ TEST_CASE("modifiers")
SECTION("other type")
{
json j = 1;
CHECK_THROWS_AS(j.push_back("Hello"), std::domain_error);
CHECK_THROWS_WITH(j.push_back("Hello"), "cannot use push_back() with number");
CHECK_THROWS_AS(j.push_back("Hello"), json::type_error);
CHECK_THROWS_WITH(j.push_back("Hello"), "[json.exception.type_error.308] cannot use push_back() with number");
}
}
......@@ -182,8 +182,8 @@ TEST_CASE("modifiers")
{
json j = 1;
json k("Hello");
CHECK_THROWS_AS(j.push_back(k), std::domain_error);
CHECK_THROWS_WITH(j.push_back(k), "cannot use push_back() with number");
CHECK_THROWS_AS(j.push_back(k), json::type_error);
CHECK_THROWS_WITH(j.push_back(k), "[json.exception.type_error.308] cannot use push_back() with number");
}
}
}
......@@ -215,9 +215,9 @@ TEST_CASE("modifiers")
{
json j = 1;
json k("Hello");
CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), std::domain_error);
CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), json::type_error);
CHECK_THROWS_WITH(j.push_back(json::object_t::value_type({"one", 1})),
"cannot use push_back() with number");
"[json.exception.type_error.308] cannot use push_back() with number");
}
}
......@@ -252,8 +252,8 @@ TEST_CASE("modifiers")
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
json k = {{"key1", 1}};
CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), std::domain_error);
CHECK_THROWS_WITH(k.push_back({1, 2, 3, 4}), "cannot use push_back() with object");
CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error);
CHECK_THROWS_WITH(k.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
}
}
}
......@@ -381,8 +381,8 @@ TEST_CASE("modifiers")
SECTION("other type")
{
json j = 1;
CHECK_THROWS_AS(j += "Hello", std::domain_error);
CHECK_THROWS_WITH(j += "Hello", "cannot use push_back() with number");
CHECK_THROWS_AS(j += "Hello", json::type_error);
CHECK_THROWS_WITH(j += "Hello", "[json.exception.type_error.308] cannot use push_back() with number");
}
}
......@@ -411,8 +411,8 @@ TEST_CASE("modifiers")
{
json j = 1;
json k("Hello");
CHECK_THROWS_AS(j += k, std::domain_error);
CHECK_THROWS_WITH(j += k, "cannot use push_back() with number");
CHECK_THROWS_AS(j += k, json::type_error);
CHECK_THROWS_WITH(j += k, "[json.exception.type_error.308] cannot use push_back() with number");
}
}
}
......@@ -444,9 +444,9 @@ TEST_CASE("modifiers")
{
json j = 1;
json k("Hello");
CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), std::domain_error);
CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), json::type_error);
CHECK_THROWS_WITH(j += json::object_t::value_type({"one", 1}),
"cannot use push_back() with number");
"[json.exception.type_error.308] cannot use push_back() with number");
}
}
......@@ -481,8 +481,8 @@ TEST_CASE("modifiers")
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
json k = {{"key1", 1}};
CHECK_THROWS_AS((k += {1, 2, 3, 4}), std::domain_error);
CHECK_THROWS_WITH((k += {1, 2, 3, 4}), "cannot use push_back() with object");
CHECK_THROWS_AS((k += {1, 2, 3, 4}), json::type_error);
CHECK_THROWS_WITH((k += {1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment