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 http response to TraktException #138

Merged
merged 1 commit into from
Mar 16, 2021
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: 2 additions & 2 deletions trakt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def _refresh_token(s):
"refresh_token is invalid"
)
elif response.status_code in s.error_map:
raise s.error_map[response.status_code]()
raise s.error_map[response.status_code](response)


def load_config():
Expand Down Expand Up @@ -521,7 +521,7 @@ def _handle_request(self, method, url, data=None):
headers=HEADERS)
self.logger.debug('RESPONSE [%s] (%s): %s', method, url, str(response))
if response.status_code in self.error_map:
raise self.error_map[response.status_code]()
raise self.error_map[response.status_code](response)
elif response.status_code == 204: # HTTP no content
return None
json_data = json.loads(response.content.decode('UTF-8', 'ignore'))
Expand Down
3 changes: 3 additions & 0 deletions trakt/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class TraktException(Exception):
"""Base Exception type for trakt module"""
http_code = message = None

def __init__(self, response=None):
self.response = response

def __str__(self):
return self.message

Expand Down