Skip to content

Commit

Permalink
Add AccountLimitExceeded error (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Jan 31, 2025
2 parents b36c9c8 + 17b3e9c commit 811da1e
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 811da1e

Please sign in to comment.