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

Converted the response from _get_url_data using to_native (#24901)

Updated the exception message to no longer use e.message.
Fixes #24526
This commit is contained in:
pdasilva 2017-05-22 12:09:51 -07:00 committed by Toshio Kuratomi
parent 014f33655c
commit 45e4b8f97a

View file

@ -330,7 +330,12 @@ class JenkinsPlugin(object):
csrf_data = self._get_json_data( csrf_data = self._get_json_data(
"%s/%s" % (self.url, "api/json"), 'CSRF') "%s/%s" % (self.url, "api/json"), 'CSRF')
try:
return csrf_data["useCrumbs"] return csrf_data["useCrumbs"]
except:
self.module.fail_json(
msg="Required fields not found in the Crum response.",
details=csrf_data)
def _get_json_data(self, url, what, **kwargs): def _get_json_data(self, url, what, **kwargs):
# Get the JSON data # Get the JSON data
@ -338,12 +343,12 @@ class JenkinsPlugin(object):
# Parse the JSON data # Parse the JSON data
try: try:
json_data = json.load(r) json_data = json.loads(to_native(r.read()))
except Exception: except Exception:
e = get_exception() e = get_exception()
self.module.fail_json( self.module.fail_json(
msg="Cannot parse %s JSON data." % what, msg="Cannot parse %s JSON data." % what,
details=e.message) details=to_native(e))
return json_data return json_data
@ -366,7 +371,7 @@ class JenkinsPlugin(object):
self.module.fail_json(msg=msg_status, details=info['msg']) self.module.fail_json(msg=msg_status, details=info['msg'])
except Exception: except Exception:
e = get_exception() e = get_exception()
self.module.fail_json(msg=msg_exception, details=e.message) self.module.fail_json(msg=msg_exception, details=to_native(e))
return response return response