faulty Of
inline fun <Error : Any> faultyOf(catch: (throwable: Throwable) -> Faulty<Error> = ::rethrow, block: RaiseScope<Error>.() -> Unit): Faulty<Error>
Context runner that encapsulates the result of block as a Faulty.
Note: catch will rethrow by default.
// Faulty<String>
faultyOf { "error" }
// Faulty<Throwable>
faultyOf { throw IllegalStateException("error") }
Content copied to clipboard
Parameters
catch
Map thrown exceptions to a Faulty. (Throws by default).
block
The code to execute.
See also
inline fun <In, Error : Any> In.faultyOf(catch: (throwable: Throwable) -> Faulty<Error> = ::rethrow, block: RaiseScope<Error>.(In) -> Unit): Faulty<Error>
Context runner that encapsulates the result of block as a Faulty.
Note: catch will rethrow by default.
// Faulty<String>
"value".faultyOf { it.uppercase() }
// Faulty<Throwable>
3.faultyOf { throw IllegalStateException("error") }
Content copied to clipboard
Receiver
Parameters
catch
Map thrown exceptions to a Faulty. (Throws by default).
block
The code to execute.