catching
inline suspend fun <Ok, Error> RaiseScope<Error>.catching(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.
Unlike catch, this suspend variant calls ensureActive before delegating to catch, so CancellationException is never silently swallowed. Prefer catching over catch in suspend contexts.
It is YOUR responsibility to use catch to handle fatal kotlin.Error cases appropriately!
val x: Fault<String> = faultOf {
catching({ "$it" }) { throw IOException() } // raises "IOException"
}Content copied to clipboard
Return
The result of block on success.
Parameters
block
The suspend block to execute.