You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
array_index does not catch std::invalid_argument exception from std::stoull, which means we need catch the exception in our code when using nlohmann json.
for example, for a json body json_body: {\"foo\":\"val\",\"bar\":\"val\",\"array\":[\"a1\",\"a2\"]}, if json pointer json_pointer was set incorrectly like /array/, when we call json_body.contains(json_pointer), it will throw std::invalid_argument exception.
Reproduction steps
for a json body json_body: {\"foo\":\"val\",\"bar\":\"val\",\"array\":[\"a1\",\"a2\"]}, if json pointer json_pointer was set incorrectly like /array/, when we call json_body.contains(json_pointer), it will throw std::invalid_argument exception.
Expected vs. actual results
Expected:
catch nlohmann::detail::exception is enough.
Actual:
just catch nlohmann::detail::exception is not enough, crush will happen due to std::invalid_argument exception.
Minimal code example
No response
Error messages
No response
Compiler and operating system
clang 7.0.1 ubuntu 18.04
Library version
3.10.5
Validation
The bug also occurs if the latest version from the develop branch is used.
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoull
v3.11.2
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_2::detail::out_of_range'
what(): [json.exception.out_of_range.404] unresolved reference token ''
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoull
v3.11.2
terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_2::detail::out_of_range'
what(): [json.exception.out_of_range.404] unresolved reference token ''
Description
array_index does not catch
std::invalid_argument
exception fromstd::stoull
, which means we need catch the exception in our code when using nlohmann json.for example, for a json body
json_body
:{\"foo\":\"val\",\"bar\":\"val\",\"array\":[\"a1\",\"a2\"]}
, if json pointerjson_pointer
was set incorrectly like/array/
, when we calljson_body.contains(json_pointer)
, it will throwstd::invalid_argument
exception.Reproduction steps
for a json body
json_body
:{\"foo\":\"val\",\"bar\":\"val\",\"array\":[\"a1\",\"a2\"]}
, if json pointerjson_pointer
was set incorrectly like/array/
, when we calljson_body.contains(json_pointer)
, it will throwstd::invalid_argument
exception.Expected vs. actual results
Expected:
catch
nlohmann::detail::exception
is enough.Actual:
just catch
nlohmann::detail::exception
is not enough, crush will happen due tostd::invalid_argument
exception.Minimal code example
No response
Error messages
No response
Compiler and operating system
clang 7.0.1 ubuntu 18.04
Library version
3.10.5
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: