1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloudflare_dns: fix KeyError (#243)

Fix errors of the type KeyError: 'success' to show a more meaningful message

Fixes: #236
This commit is contained in:
Lucas Basquerotto 2020-04-29 03:28:10 -03:00 committed by GitHub
parent 8a45044ea7
commit 055c18c892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- cloudflare_dns - fix KeyError 'success' (https://github.com/ansible-collections/community.general/issues/236).

View file

@ -496,6 +496,10 @@ class CloudflareAPI(object):
if result is None:
self.module.fail_json(msg=error_msg)
if 'success' not in result:
error_msg += "; Unexpected error details: {0}".format(result.get('error'))
self.module.fail_json(msg=error_msg)
if not result['success']:
error_msg += "; Error details: "
for error in result['errors']: