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 AccountLimitExceeded error #63

Merged
merged 4 commits into from
Jan 31, 2025
Merged
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
16 changes: 16 additions & 0 deletions trakt/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# Exceptions by HTTP status code
# https://trakt.docs.apiary.io/#introduction/status-codes
'AccountLimitExceeded',
'BadRequestException',
'OAuthException',
'ForbiddenException',
Expand Down Expand Up @@ -143,6 +144,21 @@ def details(self):
return None


class AccountLimitExceeded(RateLimitException):
"""TraktException type to be raised when a 420 return code is received"""
http_code = 420
message = 'Account Limit Exceeded - list count, item count, etc'

@property
def account_limit(self):
"""Get the account limit details from response headers.

Returns:
str|None: The value of x-account-limit header or None if not present
"""
return self.response.headers.get("x-account-limit", None)


class TraktInternalException(TraktException):
"""TraktException type to be raised when a 500 error is raised"""

Expand Down