This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow arbitrary error codes in JSON RPC server #5933
Merged
weierophinney
merged 5 commits into
zendframework:develop
from
gkralik:fix/json-rpc-error-codes
Mar 7, 2014
Merged
Allow arbitrary error codes in JSON RPC server #5933
weierophinney
merged 5 commits into
zendframework:develop
from
gkralik:fix/json-rpc-error-codes
Mar 7, 2014
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…r arbitrary codes
integers and strings are accepted as arguments, but strings need to be numerical.
This introduces a new error in |
Looks like the test asset throws an exception without setting a code. This results in the code being 0 (zero), but the test expects it to be -32000. This is a problem. Maybe we should handle this by checking for a zero code in Error:setCode and converting 0 to -32000. So everytime the user does not explicitly set an error code, it would default to -32000 |
@gkralik sounds good! Make it so! :) |
if an Exception is thrown without setting a code manually, it defaults to 0. change Error:setCode to set the code to -32000 (ERROR_OTHER) if this is the case.
Done. Tests seems to be passing now. |
weierophinney
added a commit
that referenced
this pull request
Mar 7, 2014
Allow arbitrary error codes in JSON RPC server
weierophinney
added a commit
that referenced
this pull request
Mar 7, 2014
Allow arbitrary error codes in JSON RPC server
weierophinney
added a commit
that referenced
this pull request
Mar 7, 2014
weierophinney
added a commit
that referenced
this pull request
Mar 7, 2014
weierophinney
added a commit
to zendframework/zend-json
that referenced
this pull request
May 15, 2015
…json-rpc-error-codes Allow arbitrary error codes in JSON RPC server
weierophinney
added a commit
to zendframework/zend-json
that referenced
this pull request
May 15, 2015
…json-rpc-error-codes Allow arbitrary error codes in JSON RPC server
weierophinney
added a commit
to zendframework/zend-json
that referenced
this pull request
May 15, 2015
weierophinney
added a commit
to zendframework/zend-json
that referenced
this pull request
May 15, 2015
weierophinney
added a commit
to zendframework/zend-json
that referenced
this pull request
May 15, 2015
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the implementation of Zend\Json\Server\Error limits the range of custom error codes from -32000 to -32099. According to the spec (http://www.jsonrpc.org/specification#error_object), this range is "Reserved for implementation-defined server-errors".
The spec continues "The remainder of the space is available for application defined errors". But setting a custom error code (eg 1000) is not allowed by the current implementation and results in the error code being set to -32000.
For a statement of one of the authors of the JSON-RPC specification about usable custom error codes, see this comment.
This PR aims to change the implementation to allow arbitrary error codes.