-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try/catch block does not catch parsing error #2579
Comments
I cannot reproduce this issue: https://godbolt.org/z/d396TE |
The libraries exceptions do inherit from |
Hi @nlohmann
Following the link you posted, the error message was displayed. Kindly see screenshot below. |
The error message is displayed, because of the line std::cerr << e.what() << '\n'; And that line is only executed, because the exception has be caught. |
Thanks @nlohmann You are right. There must be something wrong with my setup. I will close this and investigate my setup further. If I find anything, I'll update this thread with my findings. Thanks for your help. |
@bfamzz @nlohmann try {
throw std::runtime_error("aaaaa");
} catch (std::exception &e) {
std::cout << e.what() << "\n"; // works
}
try {
auto aaa = json::parse("{aaaa}");
} catch (json::exception &e) {
std::cout << e.what() << "\n"; // not work
} |
@xiaozhuai Can you share more information on your setup? |
What is the issue you have?
try/catch block does not catch parsing error
Error message is:
[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'A'
Please describe the steps to reproduce the issue.
Can you provide a small but working code example?
What is the expected behavior?
Error should be caught in the try/catch block and program should continue execution.
And what is the actual behavior instead?
Program crashes while in the try block. Parsing error is not caught.
Which compiler and operating system are you using?
Which version of the library did you use?
x
] latest release version 3.9.1The text was updated successfully, but these errors were encountered: