Replies: 1 comment
-
Hello same kind of question for me : I have a from_json function which used to work ok, except for the following caveat : So if I cannot throw an exception what is the correct way to report a value is invalid ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After enabling JSON_DIAGNOTICS, the path to the JSON node that cause the exception will be included in e.what() of the exception throw. This is super helpful.
My question is, when I implement from_json() for my own types, I would need to throw exception to indicate errors. How can I include the JSON path in the exception object I throw in from_json().
On the other hand, is it possible that the caller of from_json() to catch any exception thrown by it and wrap it inside a derived class of nholmann::exception, which includes the diagnotics information?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions