From: Justin Wind Date: Tue, 1 Jul 2025 21:04:06 +0000 (-0700) Subject: log errors occuring within sqlite transaction X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=50e2f6b0251919280faf24a20fc20c4bea4d3524;p=squeep-db-helper log errors occuring within sqlite transaction --- diff --git a/lib/sqlite-creator.js b/lib/sqlite-creator.js index 1a85d23..8eb5777 100644 --- a/lib/sqlite-creator.js +++ b/lib/sqlite-creator.js @@ -311,6 +311,7 @@ INSERT INTO '${this.metaVersionTable}' (major, minor, patch) VALUES (0, 0, 0);`) async transaction(dbCtx, fn) { + const _scope = _fileScope('transaction'); dbCtx = dbCtx || this.db; try { @@ -318,6 +319,9 @@ INSERT INTO '${this.metaVersionTable}' (major, minor, patch) VALUES (0, 0, 0);`) const result = await fn(dbCtx); this.statement._commit.run(); return result; + } catch (err) { + this.logger.error(_scope, 'failed in transaction', { error: err }); + throw err; } finally { if (this.db.inTransaction) { this.statement._rollback.run();