mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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:
parent
6972df76ef
commit
1ecdb7061b
1 changed files with 10 additions and 4 deletions
|
@ -349,9 +349,15 @@ class CloudflareAPI(object):
|
||||||
result = None
|
result = None
|
||||||
try:
|
try:
|
||||||
content = resp.read()
|
content = resp.read()
|
||||||
result = json.loads(content)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
if info['body']:
|
||||||
|
content = info['body']
|
||||||
|
else:
|
||||||
error_msg += "; The API response was empty"
|
error_msg += "; The API response was empty"
|
||||||
|
|
||||||
|
if content:
|
||||||
|
try:
|
||||||
|
result = json.loads(content)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
error_msg += "; Failed to parse API response: {0}".format(content)
|
error_msg += "; Failed to parse API response: {0}".format(content)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue