From 09e80a13064dee7b683b9469716f96265110db4a Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Wed, 24 May 2017 15:15:05 +0100 Subject: [PATCH] Removing unecessary exception in jenkins_plugin (#24968) --- .../web_infrastructure/jenkins_plugin.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py index 9fe4afc107e..18f2db2f8db 100644 --- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py +++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py @@ -18,10 +18,11 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -ANSIBLE_METADATA = {'metadata_version': '1.0', - 'status': ['preview'], - 'supported_by': 'community'} - +ANSIBLE_METADATA = { + 'metadata_version': '1.0', + 'status': ['preview'], + 'supported_by': 'community' +} DOCUMENTATION = ''' --- @@ -330,13 +331,13 @@ class JenkinsPlugin(object): csrf_data = self._get_json_data( "%s/%s" % (self.url, "api/json"), 'CSRF') - try: - return csrf_data["useCrumbs"] - except: + if 'useCrumbs' not in csrf_data: self.module.fail_json( - msg="Required fields not found in the Crum response.", + msg="Required fields not found in the Crumbs response.", details=csrf_data) + return csrf_data['useCrumbs'] + def _get_json_data(self, url, what, **kwargs): # Get the JSON data r = self._get_url_data(url, what, **kwargs)