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

Issue23errorcode #27

Merged
merged 7 commits into from
Jun 30, 2014
Merged

Issue23errorcode #27

merged 7 commits into from
Jun 30, 2014

Conversation

miloyip
Copy link
Collaborator

@miloyip miloyip commented Jun 27, 2014

Fixes #23. Error messages for parsing are changed to error code (ParseErrorCode).
Therefore, the error codes are possible to be handled by code instead of human.

Also, the text messages are provided optionally. This has two advantages:

  1. If an user does not need the text messages they are not linked into their program. Program size can be reduced.
  2. Users can localize the messages, either using our mechanism or roll out their own.

Unit tests are modified to verify the error codes of synthetic error cases.
Examples are modified for API changes.

API changes:

  • Removed const char* Reader::GetParseError() const.
  • Added ParseErrorCode Reader::GetParseErrorCode() const.
  • Modify semantics of RAPIDJSON_PARSE_ERROR
  • Added RAPIDJSON_PARSE_ERROR_NORETURN macro. User should customize this macro instead of RAPIDJSON_PARSE_ERROR in the past.

Parse errors is represented as enum type `ParseErrorCode`.
Error texts are optional for user.
Added  `GetParseError_En()` in `error/en.h`, user can localize this file
into other files. User may dynamically change the locale in runtime.
@miloyip
Copy link
Collaborator Author

miloyip commented Jun 27, 2014

I have not added kParseErrorLast in this request. Since I think it may give wrong impression to users. I think in future the error codes may be modified to specific numbers instead of a sequence.

I would like to invite @pah to review this pull request before merge. Thank you.

@miloyip miloyip closed this Jun 29, 2014
@miloyip miloyip deleted the issue23errorcode branch June 29, 2014 06:51
@pah
Copy link
Contributor

pah commented Jun 29, 2014

👍 As I said in #23, I like this approach.
Is there a specific reason, you closed the pull-request without merging?

@miloyip
Copy link
Collaborator Author

miloyip commented Jun 29, 2014

Oh. I accidentally closed it without merging. I will try merge it.

@miloyip miloyip restored the issue23errorcode branch June 29, 2014 23:45
@miloyip miloyip reopened this Jun 29, 2014
@miloyip miloyip closed this Jun 30, 2014
@miloyip miloyip deleted the issue23errorcode branch June 30, 2014 01:30
@miloyip miloyip restored the issue23errorcode branch June 30, 2014 01:31
@miloyip miloyip reopened this Jun 30, 2014
Conflicts:
	example/condense/condense.cpp
	include/rapidjson/reader.h
	test/unittest/readertest.cpp
miloyip added a commit that referenced this pull request Jun 30, 2014
@miloyip miloyip merged commit ba50fe7 into master Jun 30, 2014
@miloyip miloyip deleted the issue23errorcode branch June 30, 2014 02:00
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 this pull request may close these issues.

Provide error code in addition to text message
2 participants