1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-16 18:41:53 +03:00

Capture exceptions by const& in docs. (#4099)

This commit is contained in:
Ivor Wanders
2023-09-23 11:19:50 -04:00
committed by GitHub
parent 1ce29fa22f
commit aa87ab8b40
31 changed files with 49 additions and 49 deletions

View File

@ -41,7 +41,7 @@ int main()
// try to use an array index with leading '0'
json::reference ref = j.at("/array/01"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@ -52,7 +52,7 @@ int main()
// try to use an array index that is not a number
json::reference ref = j.at("/array/one"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@ -63,7 +63,7 @@ int main()
// try to use an invalid array index
json::reference ref = j.at("/array/4"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@ -74,7 +74,7 @@ int main()
// try to use the array index '-'
json::reference ref = j.at("/array/-"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@ -85,7 +85,7 @@ int main()
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@ -96,7 +96,7 @@ int main()
// try to use a JSON pointer that cannot be resolved
json::reference ref = j.at("/number/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}