Skip to content

Commit

Permalink
Add error message (#1443)
Browse files Browse the repository at this point in the history
* up

* sdk fix

* locally testing build
  • Loading branch information
shreyaspimpalgaonkar authored Oct 22, 2024
1 parent 99b65b9 commit eaeab06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/actions/start-r2r-full/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ runs:
shell: bash
run: |
cd py
poetry run r2r serve --docker --full --config-name=full
poetry run r2r serve --docker --full --config-name=full --build --image=r2r-local
14 changes: 9 additions & 5 deletions py/sdk/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@ async def _handle_response(self, response):
if response.status_code >= 400:
try:
error_content = response.json()
message = error_content.get("detail", {}).get(
"message", str(error_content)
)
if isinstance(error_content, dict):
message = error_content.get("detail", {}).get(
"message", str(error_content)
) if isinstance(error_content.get("detail"), dict) else error_content.get("detail", str(error_content))
else:
message = str(error_content)
except json.JSONDecodeError:
message = response.text()
message = response.text

raise R2RException(
status_code=response.status_code, message=message
status_code=response.status_code,
message=message
)

async def close(self):
Expand Down

0 comments on commit eaeab06

Please sign in to comment.