fix(migrations): handle specific exceptions gracefully

Updated the exception handling in the migration logic to catch `Exception` explicitly instead of using a bare except clause. This change improves the robustness of the migration process by ensuring that only known, broad exceptions are caught, aiding in debugging and maintaining the principle of least privilege in error handling. It prevents the swallowing of unrelated exceptions that could mask other issues or critical errors.
This commit is contained in:
Kumi 2024-05-18 21:39:06 +02:00
parent d0ab53b3e0
commit 89f06268a5
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -22,7 +22,7 @@ def get_version(db: SQLiteConnection) -> int:
try: try:
return int(db.execute("SELECT MAX(id) FROM migrations").fetchone()[0]) return int(db.execute("SELECT MAX(id) FROM migrations").fetchone()[0])
except: except Exception:
return 0 return 0
def migrate(db: SQLiteConnection, from_version: Optional[int] = None, to_version: Optional[int] = None) -> None: def migrate(db: SQLiteConnection, from_version: Optional[int] = None, to_version: Optional[int] = None) -> None: