Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate the 400 error codes #61

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cohere/compass/clients/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def _send_request_with_retry():
raise CompassAuthError(message=str(e))
elif 400 <= e.response.status_code < 500:
error = f"Client error occurred: {e.response.text}"
raise CompassClientError(message=error)
raise CompassClientError(message=error, code=e.response.status_code)
else:
error = str(e) + " " + e.response.text
logger.error(
Expand Down
3 changes: 2 additions & 1 deletion cohere/compass/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class CompassClientError(Exception):
"""Exception raised for all 4xx client errors in the Compass client."""

def __init__(self, message: str = "Client error occurred."):
def __init__(self, message: str = "Client error occurred.", code: int = 400):
self.message = message
self.code = code
super().__init__(self.message)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "compass-sdk"
version = "0.9.1"
version = "0.9.2"
authors = []
description = "Compass SDK"
readme = "README.md"
Expand Down
Loading