cloudflare_dns: Improve error handling (#2470)

Use the new "body" field of the info dict in case of a HTTPError.
This commit is contained in:
Michael Grüner 2016-06-23 22:15:55 +02:00 committed by René Moser
parent dbced2c809
commit 4debfcc241

View file

@ -349,9 +349,15 @@ class CloudflareAPI(object):
result = None
try:
content = resp.read()
result = json.loads(content)
except AttributeError:
if info['body']:
content = info['body']
else:
error_msg += "; The API response was empty"
if content:
try:
result = json.loads(content)
except json.JSONDecodeError:
error_msg += "; Failed to parse API response: {0}".format(content)