Skip to content

Commit

Permalink
docs: clarify that after rolling back a transaction the exception get…
Browse files Browse the repository at this point in the history
…s thrown again (#1266)

Co-authored-by: Igal Klebanov <[email protected]>
  • Loading branch information
twiddler and igalklebanov authored Nov 24, 2024
1 parent 671699f commit 7a69903
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/kysely.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ export class Kysely<DB>
* The returned {@link TransactionBuilder} can be used to configure the transaction. The
* {@link TransactionBuilder.execute} method can then be called to run the transaction.
* {@link TransactionBuilder.execute} takes a function that is run inside the
* transaction. If the function throws, the transaction is rolled back. Otherwise
* the transaction is committed.
* transaction. If the function throws an exception,
* 1. the exception is caught,
* 2. the transaction is rolled back, and
* 3. the exception is thrown again.
* Otherwise the transaction is committed.
*
* The callback function passed to the {@link TransactionBuilder.execute | execute}
* method gets the transaction object as its only argument. The transaction is
Expand All @@ -212,9 +215,12 @@ export class Kysely<DB>
*
* <!-- siteExample("transactions", "Simple transaction", 10) -->
*
* This example inserts two rows in a transaction. If an error is thrown inside
* the callback passed to the `execute` method, the transaction is rolled back.
* Otherwise it's committed.
* This example inserts two rows in a transaction. If an exception is thrown inside
* the callback passed to the `execute` method,
* 1. the exception is caught,
* 2. the transaction is rolled back, and
* 3. the exception is thrown again.
* Otherwise the transaction is committed.
*
* ```ts
* const catto = await db.transaction().execute(async (trx) => {
Expand Down

0 comments on commit 7a69903

Please sign in to comment.