Skip to content

Commit

Permalink
send http response to traktexception
Browse files Browse the repository at this point in the history
  • Loading branch information
simonc56 committed Mar 16, 2021
1 parent 18d8c5d commit 0f60294
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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

0 comments on commit 0f60294

Please sign in to comment.