Update bare exceptions to specify Exception.

This will keep us from accidentally catching program-exiting exceptions
like KeyboardInterupt and SystemExit.
This commit is contained in:
Toshio Kuratomi 2018-09-07 17:59:46 -07:00
commit 3fba006207
320 changed files with 659 additions and 656 deletions

View file

@ -93,7 +93,7 @@ msg:
try:
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlunparse
HAS_URLPARSE = True
except:
except Exception:
HAS_URLPARSE = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url

View file

@ -275,7 +275,7 @@ def main():
if secure == 'always':
module.fail_json(rc=1, msg='Unable to start an encrypted session to %s:%s: %s' %
(host, port, to_native(e)), exception=traceback.format_exc())
except:
except Exception:
pass
if not secure_state:

View file

@ -95,7 +95,7 @@ def send_msg(module):
try:
responses[number] = json.load(response)
except:
except Exception:
failed.append(number)
responses[number] = dict(failed=True)
else:

View file

@ -100,7 +100,7 @@ def main():
msg_object = Pushover(module, module.params['user_key'], module.params['app_token'])
try:
response = msg_object.run(module.params['pri'], module.params['msg'])
except:
except Exception:
module.fail_json(msg='Unable to send msg via pushover')
module.exit_json(msg='message sent successfully: %s' % response, changed=False)

View file

@ -159,7 +159,7 @@ def run_module():
syslog.closelog()
result['changed'] = True
except:
except Exception:
module.fail_json(error='Failed to write to syslog', **result)
module.exit_json(**result)