File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,8 +145,9 @@ def _parse_response(response: bytes) -> Any:
145145 try :
146146 body = json .loads (response .decode (errors = "ignore" ))
147147
148- if "error" in body :
149- message = body .get ("error" ).get ("message" )
148+ error = body .get ("error" )
149+ if error :
150+ message = error .get ("message" ) if isinstance (error , dict ) else str (error )
150151 raise ClientError (message )
151152
152153 return body .get ("result" )
Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ def test_application_error(self):
8383 with self .assertRaises (kanboard .ClientError , msg = "Internal error" ):
8484 self .client .remote_procedure ()
8585
86+ def test_application_error_non_dict (self ):
87+ body = b'{"jsonrpc": "2.0", "error": "Something went wrong", "id": 123}'
88+ self .urlopen .return_value .read .return_value = body
89+
90+ with self .assertRaises (kanboard .ClientError , msg = "Something went wrong" ):
91+ self .client .remote_procedure ()
92+
8693 def test_async_method_call_recognised (self ):
8794 method_name = "some_method_async"
8895 result = self .client .is_async_method_name (method_name )
You can’t perform that action at this time.
0 commit comments