Companion

object Companion

Functions

Link copied to clipboard
inline fun <Ok, 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.

Link copied to clipboard
inline fun <Ok, Error : Any> RaiseScope.Companion.default(action: RaiseScope<Error>.() -> Ok): Ok
Link copied to clipboard
inline fun <Ok, Error : Any> RaiseScope.Companion.default(action: RaiseScope<Error>.() -> Ok): Ok
Link copied to clipboard
inline fun <Error : Any> RaiseScope<Error>.ensure(condition: Boolean, raise: () -> Error)

Ensures that the given condition is true, otherwise raises an Error.

Link copied to clipboard
inline fun <Ok : Any, Error : Any> RaiseScope<Error>.ensureNotNull(value: Ok?, raise: () -> Error): Ok

Ensures that the given value is not null, otherwise raises an Error.

Link copied to clipboard
inline fun <In, Out, Error : Any> RaiseScope<Error>.fold(block: (scope: RaiseScope<Error>) -> In, catch: (throwable: Throwable) -> Out = ::rethrow, recover: (error: Error) -> Out, transform: (value: In) -> Out): Out
Link copied to clipboard
inline fun <Error : Any> RaiseScope<Error>.raise(error: () -> Error): Nothing

Invokes error, wraps it as a Throwable and then throws it, short-circuiting the RaiseScope execution.