runCatchingCancellable

suspend fun <T> runCatchingCancellable(block: suspend () -> T): Result<T>

Runs block and wraps its outcome in a Result, keeping cancellation intact.

This is the suspend-safe counterpart of runCatching: every ordinary failure becomes Result.failure, while cancellation still propagates.

Cancellation: a CancellationException thrown by block is rethrown, never captured in the returned Result.


suspend fun <T, R> T.runCatchingCancellable(block: suspend T.() -> R): Result<R>

Runs block with this as its receiver and wraps its outcome in a Result, keeping cancellation intact.

This is the suspend-safe counterpart of the receiver form of runCatching: every ordinary failure becomes Result.failure, while cancellation still propagates.

Cancellation: a CancellationException thrown by block is rethrown, never captured in the returned Result.