1
0
mirror of https://github.com/nlohmann/json synced 2024-12-17 22:51:07 +00:00

🚨 fix warning

This commit is contained in:
Niels Lohmann 2024-04-15 21:44:33 +02:00
parent bb2468a52c
commit 751b93652f
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
3 changed files with 4 additions and 4 deletions

View File

@ -2048,7 +2048,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
if (it == m_data.m_value.object->end())
{
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this));
JSON_THROW(out_of_range::create(403, "key not found (key is an rvalue and cannot be shown)", this));
}
return it->second;
}

View File

@ -70,11 +70,11 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
SECTION("access outside bounds")
{
CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key not found (key is an rvalue and cannot be shown)", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key not found (key is an rvalue and cannot be shown)", typename Json::out_of_range&);
#ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key not found (key is an rvalue and cannot be shown)", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key not found (key is an rvalue and cannot be shown)", typename Json::out_of_range&);
#endif
}

View File

@ -341,7 +341,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
// check exception in case of missing field
json j = json(p1);
j.erase("age");
CHECK_THROWS_WITH_AS(j.get<T>(), "[json.exception.out_of_range.403] key 'age' not found", json::out_of_range);
CHECK_THROWS_WITH_AS(j.get<T>(), "[json.exception.out_of_range.403] key not found (key is an rvalue and cannot be shown)", json::out_of_range);
}
}