@@ -50,18 +50,17 @@ def perform(self) -> Union[T, None]:
5050 if "application/json" not in resp .headers ["content-type" ]:
5151 raise_for_code_and_type (
5252 code = 500 ,
53- message = "Failed to parse JigsawStack API response. Please try again." ,
54- error_type = "InternalServerError" ,
53+ message = "Failed to parse JigsawStack API response. Please try again."
5554 )
5655
5756 # handle error in case there is a statusCode attr present
5857 # and status != 200 and response is a json.
59- if resp .status_code != 200 and resp . json (). get ( "statusCode" ) :
58+ if resp .status_code != 200 :
6059 error = resp .json ()
6160 raise_for_code_and_type (
62- code = error . get ( "statusCode" ) ,
61+ code = resp . status_code ,
6362 message = error .get ("message" ),
64- error_type = error .get ("name " ),
63+ err = error .get ("error " ),
6564 )
6665
6766 return cast (T , resp .json ())
@@ -74,18 +73,24 @@ def perform_file(self) -> Union[T, None]:
7473 # delete calls do not return a body
7574 if resp .text == "" and resp .status_code == 200 :
7675 return None
77-
78-
7976 # handle error in case there is a statusCode attr present
8077 # and status != 200 and response is a json.
81- if resp .status_code != 200 and resp .json ().get ("statusCode" ):
78+
79+
80+ if "application/json" not in resp .headers ["content-type" ] and resp .status_code != 200 :
81+ raise_for_code_and_type (
82+ code = 500 ,
83+ message = "Failed to parse JigsawStack API response. Please try again." ,
84+ error_type = "InternalServerError" ,
85+ )
86+
87+ if resp .status_code != 200 :
8288 error = resp .json ()
8389 raise_for_code_and_type (
84- code = error . get ( "statusCode" ) ,
90+ code = resp . status_code ,
8591 message = error .get ("message" ),
86- error_type = error .get ("name " ),
92+ err = error .get ("error " ),
8793 )
88-
8994 return resp
9095
9196 def perform_with_content (self ) -> T :
0 commit comments