Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 0.6.7 - 2026-09-14

- Fix error handling for TooManyRequests and Forbidden errors

## Version 0.6.6 - 2026-04-22

- Get predictions with correct output format in `create_prediction` and `get_prediction`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cradl"
version = "0.6.6"
version = "0.6.7"
description = "Python SDK for Cradl"
authors = [{ name = "Cradl", email = "hello@cradl.ai" }]
readme = "README.md"
Expand Down
9 changes: 4 additions & 5 deletions src/cradl/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ def decode_response(response, return_json=True):
raise e
except Exception as e:
logger.error('Status code {} body:\n{}'.format(response.status_code, response.text))
message = response.json().get('message', response.text)

if response.status_code == 400:
message = response.json().get('message', response.text)
raise BadRequest(message)

if response.status_code == 403 and 'Forbidden' in response.json().values():
if response.status_code == 403 and 'Forbidden' in message:
raise InvalidCredentialsException('Credentials provided are not valid.')

if response.status_code == 404:
message = response.json().get('message', response.text)
raise NotFound(message)

if response.status_code == 429 and 'Too Many Requests' in response.json().values():
if response.status_code == 429 and 'Too Many Requests' in message:
raise TooManyRequestsException('You have reached the limit of requests per second.')

if response.status_code == 429 and 'Limit Exceeded' in response.json().values():
if response.status_code == 429 and 'Limit Exceeded' in message:
raise LimitExceededException('You have reached the limit of total requests per month.')

raise e
Expand Down
Loading