catch
inline fun <Ok : Any, Error : Any> RaiseScope<Error>.catch(catch: (throwable: Throwable) -> Error = ::rethrow, block: RaiseScope<Error>.() -> Ok): Ok
A context runner use inside the RaiseScope when you wish to catch an expected (non-fatal) Throwable and convert it to an Error from your domain.
val x: Faulty<String> = faultyOf {
catch({ "$it" }) { throw IOException() } // raises "IOException"
}
Content copied to clipboard
Return
The result of the block of code.
Parameters
block
The block of code to execute.