File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/storage/src/storage3/_async Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,17 @@ async def _request(
53
53
)
54
54
response .raise_for_status ()
55
55
except HTTPStatusError as exc :
56
- resp = exc .response .json ()
57
- raise StorageApiError (resp ["message" ], resp ["error" ], resp ["statusCode" ])
56
+ try :
57
+ # try parsing JSON safely
58
+ resp = exc .response .json ()
59
+ except Exception :
60
+ resp = {}
61
+
62
+ message = resp .get ("message" ) or exc .response .text or "Unknown error"
63
+ error = resp .get ("error" ) or "UnknownError"
64
+ status_code = resp .get ("statusCode" ) or exc .response .status_code
65
+
66
+ raise StorageApiError (message , error , status_code )
58
67
59
68
# close the resource before returning the response
60
69
if files and "file" in files and isinstance (files ["file" ][1 ], BufferedReader ):
You can’t perform that action at this time.
0 commit comments