mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
fix(db): open the move's SQLite source through openDatabase, keep the drop failure as the cause
ESLint refused both: better-sqlite3 is imported only in src/db/connection.ts and its named neighbours, and an error thrown in a catch carries what that catch caught.
This commit is contained in:
@@ -256,15 +256,15 @@ async function copyAll(
|
||||
* empty before it, so everything in its schema is the move's). When even that
|
||||
* fails, the error says so, since the database then needs dropping by hand.
|
||||
*/
|
||||
async function emptyAgain(db: Kysely<object>, cause: unknown): Promise<void> {
|
||||
async function emptyAgain(db: Kysely<object>, failure: unknown): Promise<void> {
|
||||
try {
|
||||
await run(db, CLEAR_SCHEMA_SQL);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`The move failed (${cause instanceof Error ? cause.message : String(cause)}), and the schema it had created ` +
|
||||
`The move failed (${failure instanceof Error ? failure.message : String(failure)}), and the schema it had created ` +
|
||||
`could not be dropped (${err instanceof Error ? err.message : String(err)}). Drop the Postgres database and ` +
|
||||
'create it again before the next attempt.',
|
||||
{ cause },
|
||||
{ cause: err },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user