1
0
mirror of https://github.com/nlohmann/json synced 2024-11-24 04:40:13 +00:00

🚨 fix warning

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

View File

@ -2010,7 +2010,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
if (it == m_data.m_value.object->end()) 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 set_parent(it->second); return set_parent(it->second);
} }

View File

@ -21332,7 +21332,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
if (it == m_data.m_value.object->end()) 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 set_parent(it->second); return set_parent(it->second);
} }

View File

@ -39,7 +39,7 @@ TEST_CASE("Better diagnostics")
{ {
json j; json j;
j["object"]["object"] = true; j["object"]["object"] = true;
CHECK_THROWS_WITH_AS(j["object"].at("not_found"), "[json.exception.out_of_range.403] (/object) key 'not_found' not found", json::out_of_range); CHECK_THROWS_WITH_AS(j["object"].at("not_found"), "[json.exception.out_of_range.403] (/object) key not found (key is an rvalue and cannot be shown)", json::out_of_range);
} }
SECTION("array index out of range") SECTION("array index out of range")

View File

@ -69,11 +69,11 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
SECTION("access outside bounds") SECTION("access outside bounds")
{ {
CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); 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 'foo' not found", typename Json::out_of_range&);
#ifdef JSON_HAS_CPP_17 #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j.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.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 'foo' not found", typename Json::out_of_range&);
#endif #endif
} }