runCatchingCancelable

inline fun <T, R> T.runCatchingCancelable(block: T.() -> R): Result<R>

Like runCatching, but rethrows CancellationException to preserve structured concurrency. All other exceptions are captured in the Result.

Return

A Result containing the block's value or the captured exception.

Parameters

block

The block to execute.