Package-level declarations

Functions

Link copied to clipboard
Link copied to clipboard
inline fun <T> KotlinResult<T>.andIf(predicate: (T) -> Boolean, onSuccess: (T) -> T): KotlinResult<T>

If the predicate is true, transforms value inside a resultOf scope.

Link copied to clipboard
inline fun <I, O> KotlinResult<I>.andThen(onSuccess: (I) -> O): KotlinResult<O>

Transforms value inside a resultOf scope.

Link copied to clipboard

Try to get the exception of this Result.

Link copied to clipboard
inline fun <T> KotlinResult<T>.exceptionOrElse(onSuccess: (value: T) -> Throwable): Throwable

Try to get the exception of this Result.

Link copied to clipboard

Try to get the exception of this Result.

Link copied to clipboard
inline fun <In, Out> KotlinResult<In>.flatMap(onSuccess: (In) -> KotlinResult<Out>): KotlinResult<Out>

Like Result.map, applies the onSuccess function to the encapsulated value.

Link copied to clipboard

Flattens a nested KotlinResult.

Link copied to clipboard

Determines if a Throwable should be fatal.

Link copied to clipboard
inline fun <T> KotlinResult<T>.mapFailure(onFailure: (Throwable) -> Throwable): KotlinResult<T>

Transform exception into some other Throwable.

Link copied to clipboard

Re-throw a Throwable if it is fatal.

Link copied to clipboard
inline fun <T> nullable(block: () -> T): T?

Context runner that catches and normalises all non-fatal thrown exceptions into a null value.

Link copied to clipboard
inline fun <T> resultOf(block: () -> T): KotlinResult<T>

Context runner to encapsulate the result of block as a KotlinResult.

Link copied to clipboard
inline fun <T> KotlinResult<T>.tryRecover(onFailure: (Throwable) -> T): KotlinResult<T>

Transform exception into value.