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

Provide error code in addition to text message #23

Closed
miloyip opened this issue Jun 26, 2014 · 3 comments · Fixed by #27
Closed

Provide error code in addition to text message #23

miloyip opened this issue Jun 26, 2014 · 3 comments · Fixed by #27

Comments

@miloyip
Copy link
Collaborator

miloyip commented Jun 26, 2014

https://code.google.com/p/rapidjson/issues/detail?id=79
As mentioned by Anton.Breusov, currently the parsing error is provided as text string, which cannot be identified by code easily, and incurs difficulty in localization.
Provide error code.
User can obtain error message provided by rapidjson but can also localize the message by themselves.

@pah
Copy link
Contributor

pah commented Jun 27, 2014

I like the overall approach taken in the issue23errorcode branch. It's simple and effective.

Somewhat on-topic here as well (because it touches the same code parts), but rather more related to #22, I would prefer to keep a clean way to continue replacing RAPIDJSON_PARSE_ERROR with exception throwing code (as we currently use it locally). This use model is a bit more complicated now and adds unnecessary return paths, which will be dead code in case of exceptions.

We can open a new issue and provide a "standard way" to optionally use exceptions after resolving this issue.

@pah
Copy link
Contributor

pah commented Jun 27, 2014

Oh, and I should have mentioned that the issue23errorcode branch is affected by #26 as well.

@miloyip
Copy link
Collaborator Author

miloyip commented Jun 27, 2014

I think supporting exception is possible. The dead code ("early return check") can be disabled by preprocessing.
But I don't think exception is really needed. The downside of it is performance overhead and unwinding code overhead.
Can you think of some reasons for supporting it?
If user just want to use try/catch syntax instead of calling GetParseErrorCode(), we can just throw an exception at Parse() function.

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

Successfully merging a pull request may close this issue.

2 participants