resultOf

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

Context runner to encapsulate the result of block as a nz.adjmunro.outcome.result.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.


inline fun <In, Out> In.resultOf(block: In.() -> Out): KotlinResult<Out>

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

In

The receiver type of block.

Out

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.