Skip to content

Commit 72cfc74

Browse files
committed
fix: always throw error on rollback
1 parent e0a84b5 commit 72cfc74

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

package/src/operations/transaction.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,15 @@ export const transaction = async <Result = void>(
7979

8080
return result
8181
} catch (executionError) {
82-
if (isFinalized) {
83-
throw NitroSQLiteError.fromError(executionError)
82+
if (!isFinalized) {
83+
try {
84+
rollback()
85+
} catch (rollbackError) {
86+
throw NitroSQLiteError.fromError(rollbackError)
87+
}
8488
}
8589

86-
try {
87-
rollback()
88-
return undefined as Result
89-
} catch (rollbackError) {
90-
throw NitroSQLiteError.fromError(rollbackError)
91-
}
90+
throw NitroSQLiteError.fromError(executionError)
9291
}
9392
})
9493
}

0 commit comments

Comments
 (0)