Skip to content

Commit 756479b

Browse files
Catch specific errors
1 parent a2ed4fc commit 756479b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

seam/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ def _handle_error_response(self, response: requests.Response):
8383
def _is_api_error_response(self, response: requests.Response) -> bool:
8484
try:
8585
content_type = response.headers.get("content-type", "")
86+
8687
if not isinstance(content_type, str) or not content_type.startswith(
8788
"application/json"
8889
):
8990
return False
91+
except ValueError:
92+
return False
9093

94+
try:
9195
data = response.json()
92-
except Exception:
96+
except requests.exceptions.JSONDecodeError:
9397
return False
9498

9599
if not isinstance(data, dict):

0 commit comments

Comments
 (0)