Skip to content

Commit 649057b

Browse files
committed
[try_]with_tx: clarify panics
1 parent 5e245ea commit 649057b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

crates/bindings/src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,12 @@ impl ProcedureContext {
11031103
/// Acquire a mutable transaction
11041104
/// and execute `body` with read-write access to the database.
11051105
///
1106-
/// When a panic occurs,
1107-
/// the transaction will be rolled back and its mutations discarded.
1106+
/// If `body` panics, the transaction will be rolled back,
1107+
/// and the calling procedure terminated.
11081108
/// Otherwise, the transaction will be committed and its mutations persisted.
1109+
/// Prefer calling [`Self::try_with_tx`]
1110+
/// and returning a `Result` for signaling errors
1111+
/// to allow the calling procedure to handle the transaction's failure.
11091112
///
11101113
/// Regardless of the transaction's success or failure,
11111114
/// the return value of `body` is not persisted to the commitlog
@@ -1135,11 +1138,16 @@ impl ProcedureContext {
11351138
/// Acquire a mutable transaction
11361139
/// and execute `body` with read-write access to the database.
11371140
///
1138-
/// When `body().is_ok()`,
1141+
/// When `body` returns `Ok`,
11391142
/// the transaction will be committed and its mutations persisted.
1140-
/// When `!body().is_ok()` or a panic occurs in `body`,
1143+
/// When `body` returns `Err`,
11411144
/// the transaction will be rolled back and its mutations discarded.
11421145
///
1146+
/// If `body` panics, the transaction will be rolled back,
1147+
/// and the calling procedure terminated.
1148+
/// Prefer returning `Result` for signaling errors
1149+
/// to allow the calling procedure to handle the transaction's failure.
1150+
///
11431151
/// Regardless of the transaction's success or failure,
11441152
/// the return value of `body` is not persisted to the commitlog
11451153
/// or broadcast to subscribed clients.

0 commit comments

Comments
 (0)