From 35c6f6c3bc6ff049bac6994ab0ef1516bf029fe1 Mon Sep 17 00:00:00 2001 From: twolaw Date: Sun, 14 Mar 2021 21:01:47 +0100 Subject: [PATCH] send http response to traktexceptions --- trakt/core.py | 4 ++-- trakt/errors.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) 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..89b59eda 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): + self.response = response + def __str__(self): return self.message