mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Ensure that current uses of BaseException are required
* In some cases, it appears that Exception should have been used instead as there's no need to catch sys.exit KeyboardInterrupt and similar. * In a few cases, it appears that BaseException is used because a library we depend on calls sys.exit() contrary to good coding design. Comment those so that we know that those have been audited and found to be correct and change to use (Exception, SystemExit) instead.
This commit is contained in:
@@ -173,7 +173,9 @@ class ZabbixInventory(object):
|
||||
try:
|
||||
api = ZabbixAPI(server=self.zabbix_server, validate_certs=self.validate_certs)
|
||||
api.login(user=self.zabbix_username, password=self.zabbix_password)
|
||||
except BaseException as e:
|
||||
# zabbix_api tries to exit if it cannot parse what the zabbix server returned
|
||||
# so we have to use SystemExit here
|
||||
except (Exception, SystemExit) as e:
|
||||
print("Error: Could not login to Zabbix server. Check your zabbix.ini.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user