1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-22 15:21:52 +03:00

📝 added exception 403 to documentation of at (#888)

The at function throws json::out_of_range.403 when a nonexistent object key is provided (just like the usual at function). This was not documented and users could assume json::out_of_range.404 would be thrown instead.

- Updated documentation.
- Added example code.
This commit is contained in:
Niels Lohmann
2017-12-23 18:38:18 +01:00
parent 184e9c6aa7
commit 3113a52a7d
8 changed files with 38 additions and 3 deletions

View File

@ -79,6 +79,17 @@ int main()
std::cout << e.what() << '\n';
}
// out_of_range.403
try
{
// try to use a JSON pointer to an nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.404
try
{