Skip to content

Commit

Permalink
Merge pull request #59 from AryaXAI/sdk-v2
Browse files Browse the repository at this point in the history
api error handling
  • Loading branch information
chintanarya authored Nov 4, 2024
2 parents ea42334 + 8d391e7 commit 1d049d1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aryaxai/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@ def base_request(self, method, uri, payload={}, files=None, stream=False):
files=files,
stream=stream,
)
res = None
try:
res = response.json().get("details") or response.json()
except Exception:
res = response.text
if 400 <= response.status_code < 500:
raise Exception(response.json())
raise Exception(res)
elif 500 <= response.status_code < 600:
raise Exception(response.text)
raise Exception(res)
else:
return response
except Exception as e:
Expand Down

0 comments on commit 1d049d1

Please sign in to comment.