2.0 Error codes

209 views
Skip to first unread message

Alex Storkey

unread,
Mar 19, 2013, 11:46:06 AM3/19/13
to json...@googlegroups.com
Hi,

I'm looking for clarification on error codes in the 2.0 spec.

As far as I understand it, the json-rpc spec only allows the API developer to utilize error codes within the range -32000 to -32099. Am I mistaken in this assumption? This limitation seems quite bizarre to me.

FYI, the reason for my asking is this GitHub issue here https://github.com/zendframework/zf2/issues/2456 which has been caused by a lot of developers possibly misunderstanding the spec document.

Thanks.

James Cooper

unread,
Mar 19, 2013, 12:10:40 PM3/19/13
to json...@googlegroups.com
My interpretation is that "-32000 to -32099 Server error Reserved for implementation-defined server-errors." means that the JSON-RPC implementation (e.g. Zend framework's JSON-RPC impl) can use this range for implementation specific errors.

Whereas "The remainder of the space is available for application defined errors." means that folks writing apps using the JSON-RPC implementation can use any other number as an error code.  For example, you write a service with a method "foo()" that raises errors 1000, 1001, 1002.  That's fine.

To summarize, I think the spec intends "implementation-defined" to be errors raised directly by the framework/library, as opposed to "application defined" which are raised by arbitrary code written by users of the framework/library.

-- James

--
You received this message because you are subscribed to the Google Groups "JSON-RPC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-rpc+u...@googlegroups.com.
To post to this group, send email to json...@googlegroups.com.
Visit this group at http://groups.google.com/group/json-rpc?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

James Cooper
http://blog.bitmechanic.com/

Roland Koebler

unread,
Mar 19, 2013, 2:11:45 PM3/19/13
to json...@googlegroups.com
Hi,

On Tue, Mar 19, 2013 at 09:10:40AM -0700, James Cooper wrote:
> My interpretation is that "-32000 to -32099 Server error Reserved for
> implementation-defined server-errors." means that the JSON-RPC
> implementation (e.g. Zend framework's JSON-RPC impl) can use this range for
> implementation specific errors.
>
> Whereas "The remainder of the space is available for application defined
> errors." means that folks writing apps using the JSON-RPC implementation
> can use any other number as an error code. For example, you write a
> service with a method "foo()" that raises errors 1000, 1001, 1002. That's
> fine.
>
> To summarize, I think the spec intends "implementation-defined" to be
> errors raised directly by the framework/library, as opposed to "application
> defined" which are raised by arbitrary code written by users of the
> framework/library.
your interpretation is completely correct.
-32768 to -32000 are reserved for pre-defined errors,
-32099 to -32000 are reserved for JSON-RPC-server/framework/library-implementations,
codes > -32000 (and < -32768) can freely be used by applications.


Roland
Reply all
Reply to author
Forward
0 new messages