better error handling on network

This commit is contained in:
Andy Pack 2022-12-23 10:23:36 +00:00
parent 047c3c33ea
commit e139da019c
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7

View File

@ -171,7 +171,10 @@ class Network:
try:
error_json = response.json()
error_message = error_json.get("error", {}).get("message", error_json)
error_message = error_json.get("error", {})
if isinstance(error_message, dict):
error_message = error_message.get("message", error_json)
logger.error(f'{method} {response.status_code} {error_message}')
raise SpotifyNetworkException(http_code=response.status_code, message=error_message)