resultOf

inline fun <T> resultOf(block: () -> T): KotlinResult<T>

Context runner to encapsulate the result of block as a KotlinResult.

For example, CancellationException, which is necessary for Kotlin's structured concurrency model, is considered fatal and will always be rethrown. Read more about issues with Kotlin's runCatching()

Parameters

T

The return type of block.

block

The protected try-block which may throw and exception.

See also

nonFatalOrThrow

Throws

See Throwable.isFatal for list of unsafe exceptions.