Specify the ‘Exception’ catch-all exception class, not a bare ‘except’.
PEP 8 specifies: * When catching exceptions, mention specific exceptions whenever possible instead of using a bare `except:` clause […] A bare `except:` clause will catch `SystemExit` and `KeyboardInterrupt` exceptions, making it harder to interrupt a program with Control-C, and can disguise other problems. If you want to catch all exceptions that signal program errors, use `except Exception:` (bare except is equivalent to `except BaseException:`).
This commit is contained in:
parent
6a4de62467
commit
1ad357ba4a
1 changed files with 1 additions and 1 deletions
|
@ -61,7 +61,7 @@ try:
|
||||||
)
|
)
|
||||||
database.set_session(readonly=True, autocommit=True)
|
database.set_session(readonly=True, autocommit=True)
|
||||||
logging.debug(database.get_dsn_parameters())
|
logging.debug(database.get_dsn_parameters())
|
||||||
except:
|
except Exception:
|
||||||
logging.error("Unable to initialize database, check settings!")
|
logging.error("Unable to initialize database, check settings!")
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue