Skip to content

Commit

Permalink
Add details RateLimitException to parse x-ratelimit header
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 8, 2024
1 parent 0f8c5b8 commit f6992f8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions trakt/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ class RateLimitException(TraktException):
def retry_after(self):
return int(self.response.headers.get("Retry-After", 1))

@property
def details(self):
from json import JSONDecodeError, loads

try:
return loads(self.response.headers.get("x-ratelimit", ""))
except JSONDecodeError:
return None


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

0 comments on commit f6992f8

Please sign in to comment.