Dont raise internal error for server exceptions

Issue #13 resolved
Sunil Mohan Adapa
created an issue

Currenly when the application raises an exception, an 'Internal Error' is being sent to the client. I believe that according to JSON RPC 2.0 spec[1] and XML-RPC spec[2] which it refers to, 'Internal Error's are meant for errors that happen within the JSON RPC library. Errors from application code have to handled differently.



def foo(): ... raise Exception('foo exception') ... from jsonrpc2 import JsonRpc rpc = JsonRpc() rpc['foo'] = foo rpc({'jsonrpc': '2.0', 'method': 'foo', 'id': 'rpc-1', 'params': {}}) {'jsonrpc': '2.0', 'id': 'rpc-1', 'error': {'message': 'Internal Error', 'code': -32603, 'data': 'foo exception'}} }}}

Expected result: {{{


{'jsonrpc': '2.0', 'id': 'rpc-1', 'error': {'message': 'foo exception', 'code': -32000}} }}}

=== Links ==

Comments (2)

  1. Log in to comment