@@ -137,21 +137,27 @@ def get_request(self, *args, **argsn):
137137    def  __call__ (self , * args , ** argsn ):
138138        postdata  =  json .dumps (self .get_request (* args , ** argsn ), default = EncodeDecimal , ensure_ascii = self .ensure_ascii )
139139        response , status  =  self ._request ('POST' , self .__url .path , postdata .encode ('utf-8' ))
140-         if  response ['error' ] is  not None :
141-             raise  JSONRPCException (response ['error' ])
140+ 
141+         error_response  =  response ['error' ]
142+         if  'code'  not  in error_response :
143+             error_response ['code' ] =  - 1 
144+             raise  JSONRPCException ({'error' : error_response , 'status' : status })
142145        elif  'result'  not  in response :
143146            raise  JSONRPCException ({
144147                'code' : - 343 , 'message' : 'missing JSON-RPC result' })
148+         elif  status  !=  HTTPStatus .OK :
149+             raise  JSONRPCException ({
150+                 'code' : - 342 , 'message' : 'non-200 HTTP status code but no JSON-RPC error' })
145151        else :
146152            assert  response ['jsonrpc' ] ==  '2.0' 
147153            if  status  !=  HTTPStatus .OK :
148154                raise  JSONRPCException ({
149-                     'code' : - 342 , 'message' : 'non-200 HTTP status code' },  status )
155+                     'code' : - 342 , 'message' : 'non-200 HTTP status code' })
150156            if  'error'  in  response :
151-                 raise  JSONRPCException (response ['error' ], status )
157+                 raise  JSONRPCException ({ 'error' :  response ['error' ], ' status' :  status } )
152158            elif  'result'  not  in response :
153159                raise  JSONRPCException ({
154-                     'code' : - 343 , 'message' : 'missing JSON-RPC 2.0 result and error' },  status )
160+                     'code' : - 343 , 'message' : 'missing JSON-RPC 2.0 result and error' })
155161            return  response ['result' ]
156162
157163    def  batch (self , rpc_call_list ):
@@ -195,7 +201,8 @@ def _get_response(self):
195201            log .debug ("<-%s- [%.6f] %s"  %  (response ["id" ], elapsed , json .dumps (response ["result" ], default = EncodeDecimal , ensure_ascii = self .ensure_ascii )))
196202        else :
197203            log .debug ("<-- [%.6f] %s"  %  (elapsed , responsedata ))
198-         return  response 
204+         return  response , http_response .status 
205+ 
199206
200207    def  __truediv__ (self , relative_uri ):
201208        return  AuthServiceProxy ("{}/{}" .format (self .__service_url , relative_uri ), self ._service_name , connection = self .__conn )
0 commit comments