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.
- Sample code is provided below.
Can you provide a small but working code example?
#include<iostream>
#include <nlohmann/json.hpp>
int main()
{
try
{
nlohmann::json jsonObject = nlohmann::json::parse("Alright");
std::cout << "Parse completed!\n";
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
return -1;
}
return 0;
}
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?
- Compiler: GCC 9.3.0 && GCC 10.1.0
- Operating system: Linux - Ubuntu 20.04
Which version of the library did you use?
- [
x] latest release version 3.9.1
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.1