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:
Ben Finney 2022-12-19 09:45:39 +11:00
parent 6a4de62467
commit 1ad357ba4a
1 changed files with 1 additions and 1 deletions

View File

@ -61,7 +61,7 @@ try:
)
database.set_session(readonly=True, autocommit=True)
logging.debug(database.get_dsn_parameters())
except:
except Exception:
logging.error("Unable to initialize database, check settings!")
time.sleep(10)
sys.exit(1)