mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudflare_dns: minor code improvments
Tweaked some things on top of the well done PR #1768 - json import - fix expetion handling - fix indentation
This commit is contained in:
parent
68fc8e75f6
commit
39ece09e86
1 changed files with 13 additions and 6 deletions
|
@ -18,7 +18,14 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
|
pass
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
|
@ -263,7 +270,7 @@ class CloudflareAPI(object):
|
||||||
result = json.loads(content)
|
result = json.loads(content)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
error_msg += "; The API response was empty"
|
error_msg += "; The API response was empty"
|
||||||
except JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
error_msg += "; Failed to parse API response: {0}".format(content)
|
error_msg += "; Failed to parse API response: {0}".format(content)
|
||||||
|
|
||||||
# received an error status but no data with details on what failed
|
# received an error status but no data with details on what failed
|
||||||
|
|
Loading…
Add table
Reference in a new issue