MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / withOpenFailures

Function withOpenFailures

src/db/index.ts:60–67  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

58 * leaves no connection open.
59 */
60function 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

Callers 2

initializeMethod · 0.85
openMethod · 0.85

Calls 3

toDatabaseOpenErrorFunction · 0.90
closeMethod · 0.65
finishFunction · 0.50

Tested by

no test coverage detected