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

Add a specific exception for rate limiting #53

Merged
merged 1 commit into from
Mar 23, 2017
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: 2 additions & 0 deletions bigcommerce/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def _handle_response(self, url, res, suppress_empty=True):
raise EmptyResponseWarning("%d %s @ %s: %s" % (res.status_code, res.reason, url, res.content), res)
elif res.status_code >= 500:
raise ServerException("%d %s @ %s: %s" % (res.status_code, res.reason, url, res.content), res)
elif res.status_code == 429:
raise RateLimitingException("%d %s @ %s: %s" % (res.status_code, res.reason, url, res.content), res)
elif res.status_code >= 400:
raise ClientRequestException("%d %s @ %s: %s" % (res.status_code, res.reason, url, res.content), res)
elif res.status_code >= 300:
Expand Down
3 changes: 3 additions & 0 deletions bigcommerce/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class EmptyResponseWarning(HttpException):
# 4xx codes
class ClientRequestException(HttpException):
pass

class RateLimitingException(ClientRequestException):
pass
# class Unauthorised(ClientRequestException): pass
# class AccessForbidden(ClientRequestException): pass
# class ResourceNotFound(ClientRequestException): pass
Expand Down