From b788cec79be565d3df44fb70c5b2b4e1af59ab5d Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 7 Aug 2025 10:32:09 -0700 Subject: [PATCH] fix: include original error in ROLLBACK failure --- lib/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index b517c80..424db67 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -555,7 +555,14 @@ export default class Database { commit.run(); return result; } catch (error) { - rollback.run(); + try { + rollback.run(); + } catch (rollbackError) { + if (rollbackError instanceof Error) { + rollbackError.cause = error; + } + throw rollbackError; + } throw error; } finally { this.#transactionDepth -= 1;