mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-08 15:42:48 +00:00
better handling when missing json payload
This commit is contained in:
parent
550be583b7
commit
38ea4b6910
@ -104,7 +104,7 @@ class Spotify(object):
|
|||||||
try:
|
try:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except:
|
except:
|
||||||
if r.text:
|
if r.text and len(r.text) > 0 and r.text != 'null':
|
||||||
raise SpotifyException(r.status_code,
|
raise SpotifyException(r.status_code,
|
||||||
-1, '%s:\n %s' % (r.url, r.json()['error']['message']))
|
-1, '%s:\n %s' % (r.url, r.json()['error']['message']))
|
||||||
else:
|
else:
|
||||||
@ -112,7 +112,7 @@ class Spotify(object):
|
|||||||
-1, '%s:\n %s' % (r.url, 'error'))
|
-1, '%s:\n %s' % (r.url, 'error'))
|
||||||
finally:
|
finally:
|
||||||
r.connection.close()
|
r.connection.close()
|
||||||
if len(r.text) > 0:
|
if r.text and len(r.text) > 0 and r.text != 'null':
|
||||||
results = r.json()
|
results = r.json()
|
||||||
if self.trace: # pragma: no cover
|
if self.trace: # pragma: no cover
|
||||||
print('RESP', results)
|
print('RESP', results)
|
||||||
|
Loading…
Reference in New Issue
Block a user