json-rpc
json-rpc copied to clipboard
custom define for application defined errors.
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
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