@@ -782,7 +782,7 @@ class Fault(object):
782
782
JSON-RPC error class
783
783
"""
784
784
def __init__ (self , code = - 32000 , message = 'Server error' , rpcid = None ,
785
- config = jsonrpclib .config .DEFAULT ):
785
+ config = jsonrpclib .config .DEFAULT , data = None ):
786
786
"""
787
787
Sets up the error description
788
788
@@ -795,14 +795,15 @@ def __init__(self, code=-32000, message='Server error', rpcid=None,
795
795
self .faultString = message
796
796
self .rpcid = rpcid
797
797
self .config = config
798
+ self .data = data
798
799
799
800
def error (self ):
800
801
"""
801
802
Returns the error as a dictionary
802
803
803
804
:returns: A {'code', 'message'} dictionary
804
805
"""
805
- return {'code' : self .faultCode , 'message' : self .faultString }
806
+ return {'code' : self .faultCode , 'message' : self .faultString , 'data' : self . data }
806
807
807
808
def response (self , rpcid = None , version = None ):
808
809
"""
@@ -923,7 +924,7 @@ def response(self, result=None):
923
924
924
925
return response
925
926
926
- def error (self , code = - 32000 , message = 'Server error.' ):
927
+ def error (self , code = - 32000 , message = 'Server error.' , data = None ):
927
928
"""
928
929
Prepares an error dictionary
929
930
@@ -937,6 +938,8 @@ def error(self, code=-32000, message='Server error.'):
937
938
else :
938
939
error ['result' ] = None
939
940
error ['error' ] = {'code' : code , 'message' : message }
941
+ if data is not None :
942
+ error ['error' ]['data' ] = data
940
943
return error
941
944
942
945
# ------------------------------------------------------------------------------
@@ -983,7 +986,7 @@ def dump(params=None, methodname=None, rpcid=None, version=None,
983
986
if isinstance (params , Fault ):
984
987
# Prepare an error dictionary
985
988
# pylint: disable=E1103
986
- return payload .error (params .faultCode , params .faultString )
989
+ return payload .error (params .faultCode , params .faultString , params . data )
987
990
988
991
if not isinstance (methodname , utils .string_types ) and not is_response :
989
992
# Neither a request nor a response
0 commit comments