diff --git a/trakt/core.py b/trakt/core.py index 39d72177..efd8c696 100644 --- a/trakt/core.py +++ b/trakt/core.py @@ -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(): @@ -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')) diff --git a/trakt/errors.py b/trakt/errors.py index 7d69f10f..4dc8d753 100644 --- a/trakt/errors.py +++ b/trakt/errors.py @@ -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