catchException

inline fun <Ok> catchException(scope: RaiseScope<Exception> = DefaultRaiseScope(), block: RaiseScope<Exception>.() -> Ok): Outcome<Ok, Exception>

Runs block and wraps the result as an Outcome, using Exception as the error type.

Every thrown Exception is captured and wrapped in a Failure automatically. Use this when any exception is an acceptable error signal, and you don't need a narrower error type.

Warning: Does not propagate kotlinx.coroutines.CancellationException — use outcomeOf in suspend contexts.

See also