Issue #13 resolved

Dont raise internal error for server exceptions

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.

{{{

!python

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: {{{

!python

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

=== Links ==

http://www.jsonrpc.org/specification

http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php

Comments (2)

  1. Log in to comment