Skip to content
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

Question about exceptions #173

Closed
dummy0stud opened this issue Jan 6, 2016 · 4 comments
Closed

Question about exceptions #173

dummy0stud opened this issue Jan 6, 2016 · 4 comments

Comments

@dummy0stud
Copy link

There is any possible way of using this lib without exceptions, or it always throws?

It would be nice something like:

json j =R"({,})"_json;
std::cout << j.is_parsed_sucess();
@nlohmann
Copy link
Owner

In case of a parse error, the code will always throw an exception. So far, I do not plan to make exceptions optional.

For your use case, you may catch std::invalid_argument and create a wrapper function is_parsed_success yourself.

@berkus
Copy link
Contributor

berkus commented Mar 16, 2017

std::invalid_argument does not work.

On a related note, I don't see a single word about JSON parsing errors in the documentation.

@gregmarr
Copy link
Contributor

FYI, it is now possible to disable exceptions in the library.

@nlohmann
Copy link
Owner

@berkus The last released version works with std::invalid_argument. The develop branch contains an unreleased version with user-defined exceptions. There, the parser throws json::parse_error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants