Print raw response when JSON fails to parse

If the response to the Tautulli API fails to parse correctly include the 
raw output in the message to make it easier to diagnose when the 
response isn't actually raw JSON from a Tautulli server (e.g. a proxy 
server).
This commit is contained in:
Landon Abney
2019-10-27 20:04:36 -07:00
parent 645c43708a
commit 66ac37b34e

View File

@ -268,7 +268,9 @@ class Tautulli:
try: try:
response_json = response.json() response_json = response.json()
except ValueError: except ValueError:
print("Failed to parse json response for Tautulli API cmd '{}'".format(cmd)) print(
"Failed to parse json response for Tautulli API cmd '{}': {}"
.format(cmd, response.content))
return return
if response_json['response']['result'] == 'success': if response_json['response']['result'] == 'success':