Skip to content

Commit b788cec

Browse files
fix: include original error in ROLLBACK failure
1 parent 26e1566 commit b788cec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,14 @@ export default class Database {
555555
commit.run();
556556
return result;
557557
} catch (error) {
558-
rollback.run();
558+
try {
559+
rollback.run();
560+
} catch (rollbackError) {
561+
if (rollbackError instanceof Error) {
562+
rollbackError.cause = error;
563+
}
564+
throw rollbackError;
565+
}
559566
throw error;
560567
} finally {
561568
this.#transactionDepth -= 1;

0 commit comments

Comments
 (0)