catch
inline fun <Ok, Error> RaiseScope<Error>.catch(catch: (throwable: Throwable) -> Error = ::rethrow, block: RaiseScope<Error>.() -> Ok): Ok
Executes block inside the current RaiseScope, converting any thrown Throwable — including fatal kotlin.Error subclasses — to a raised Error via catch.
Warning: CancellationException is not propagated. Use catching in suspend contexts.
It is YOUR responsibility to use catch to handle fatal kotlin.Error cases appropriately!
val x: Fault<String> = fault {
catch({ "$it" }) { throw IOException() } // raises "IOException"
}Content copied to clipboard
Return
The result of block on success.