Skip to content

Commit

Permalink
Add details to BadResponseException of json error
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 15, 2022
1 parent 8bb6b51 commit 0e92938
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions trakt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from requests_oauthlib import OAuth2Session
from datetime import datetime, timedelta, timezone
from trakt import errors
from trakt.errors import BadResponseException

__author__ = 'Jon Nappi'
__all__ = ['Airs', 'Alias', 'Comment', 'Genre', 'get', 'delete', 'post', 'put',
Expand Down Expand Up @@ -533,8 +534,8 @@ def _handle_request(self, method, url, data=None):

try:
json_data = json.loads(response.content.decode('UTF-8', 'ignore'))
except JSONDecodeError:
raise errors.BadResponseException(response)
except JSONDecodeError as e:
raise BadResponseException(response, f"Unable to parse JSON: {e}")

return json_data

Expand Down

0 comments on commit 0e92938

Please sign in to comment.