Skip to content

Commit

Permalink
Propagate the 400 error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
benrules3 committed Dec 11, 2024
1 parent ec32e5b commit 3c48b64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cohere/compass/clients/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,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
4 changes: 3 additions & 1 deletion cohere/compass/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

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

0 comments on commit 3c48b64

Please sign in to comment.