json-rpc icon indicating copy to clipboard operation
json-rpc copied to clipboard

custom define for application defined errors.

Open sevenjay opened this issue 9 years ago • 1 comments

the spec. mentions that "-32000 to -32099 Server error Reserved for implementation-defined server-errors."

The remainder of the space is available for application defined errors. Could we have custom define errors for application in the future? Like:

    return JSONRPCError(-32000, "Empty Request").as_response()

or just let user define class JSONRPCEmptyRequest(JSONRPCError) Thanks

sevenjay avatar Nov 24 '15 14:11 sevenjay

Dear @sevenjay , please take a look at custom exceptions here: https://json-rpc.readthedocs.org/en/latest/exceptions.html#json-rpc-exceptions

to define one, you would need to create custom exception class, inherited from jsonrpc.exceptions.JSONRPCDispatchException. Check out this test as well: https://github.com/pavlov99/json-rpc/blob/master/jsonrpc/tests/test_jsonrpc_errors.py#L143-L149

pavlov99 avatar Dec 12 '15 15:12 pavlov99