Fix cloudflare_dns JSON response error handling (#42894)
* The JSONDecodeError exception only exists in Python 3. * Without a properly parsed JSON response there is no more error processing to be done, no matter the http response code. Relates to #38178
This commit is contained in:
parent
4e489d1be8
commit
c6854fde29
1 changed files with 3 additions and 3 deletions
|
@ -354,11 +354,11 @@ class CloudflareAPI(object):
|
|||
if content:
|
||||
try:
|
||||
result = json.loads(to_text(content, errors='surrogate_or_strict'))
|
||||
except (json.JSONDecodeError, UnicodeError) as e:
|
||||
except (getattr(json, 'JSONDecodeError', ValueError)) as e:
|
||||
error_msg += "; Failed to parse API response with error {0}: {1}".format(to_native(e), content)
|
||||
|
||||
# received an error status but no data with details on what failed
|
||||
if (info['status'] not in [200, 304]) and (result is None):
|
||||
# Without a valid/parsed JSON response no more error processing can be done
|
||||
if result is None:
|
||||
self.module.fail_json(msg=error_msg)
|
||||
|
||||
if not result['success']:
|
||||
|
|
Loading…
Reference in a new issue