* Run the rest of an open on the connection `db`. Its first statements read * the file, so a database SQLite cannot use (locked, damaged, not a database, * an I/O error) fails here as well as when the connection is made. Such a * failure names SQLite's code and the path (DatabaseOpenError
(db: SqliteDatabase, dbPath: string, finish: () => T)
| 58 | * leaves no connection open. |
| 59 | */ |
| 60 | function withOpenFailures<T>(db: SqliteDatabase, dbPath: string, finish: () => T): T { |
| 61 | try { |
| 62 | return finish(); |
| 63 | } catch (err) { |
| 64 | try { db.close(); } catch { /* the open's failure is the one to report */ } |
| 65 | throw toDatabaseOpenError(err, dbPath); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * WAL size past which `healOversizedWal` (run at every `open`) checkpoints and |
no test coverage detected