Package com.github.michaelbull.result.coroutines

Functions

Link copied to clipboard
inline fun <V> runSuspendCatching(block: () -> V): Result<V, Throwable>

Calls the specified function block and returns its encapsulated result if invocation was successful, catching any Throwable exception that was thrown from the block function execution and encapsulating it as a failure. If the encapsulated failure is a CancellationException, the exception is thrown to indicate normal cancellation of a coroutine.

infix inline fun <T, V> T.runSuspendCatching(block: T.() -> V): Result<V, Throwable>

Calls the specified function block with this value as its receiver and returns its encapsulated result if invocation was successful, catching any Throwable exception that was thrown from the block function execution and encapsulating it as a failure. If the encapsulated failure is a CancellationException, the exception is thrown to indicate normal cancellation of a coroutine.