runCatchingCancellable

inline fun <R> runCatchingCancellable(block: () -> R): Result<R>

Like runCatching, but rethrows CancellationException to preserve coroutine cancellation semantics.

Return

a Result wrapping the success value or the caught exception (excluding CancellationException)

Parameters

block

the code to execute

Type Parameters

R

the result type

Throws

CancellationException

if the block throws a cancellation exception