Skip to content

Commit

Permalink
Catch exceptions around Twitch json decode (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
aw-was-here committed Dec 31, 2023
1 parent ebed699 commit 759e456
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nowplaying/twitch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ def qtsafe_validate_token(token):
except Exception as error: #pylint: disable=broad-except
logging.error('Twitch Token validation check failed:%s', error)
return None
try:
valid = req.json()
except Exception as error: #pylint: disable=broad-except
logging.error('Twitch Token validation/bad json:%s', error)
return None

valid = req.json()
if valid.get('status') == 401:
logging.debug('Twitch token is invalid')
return None
Expand Down

0 comments on commit 759e456

Please sign in to comment.