From e2b139d7ef346f2455815c394226c1b7909a733e Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 7 Aug 2025 10:22:59 -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;