Failure

data class Failure<out E>(val error: E) : Result<Nothing, E>

Constructors

Link copied to clipboard
constructor(error: E)

Properties

Link copied to clipboard
val error: E

Functions

Link copied to clipboard
fun <D, E> Result<D, E>.asEmpty(): EmptyResult<E>

Discard the success payload, keeping only success-vs-failure.

Link copied to clipboard
fun <D, E> Result<D, E>.errorOrNull(): E?
Link copied to clipboard
inline fun <D, E, R> Result<D, E>.flatMap(transform: (D) -> Result<R, E>): Result<R, E>

Chain a success into another Result; failures short-circuit.

Link copied to clipboard
inline fun <D, E, R> Result<D, E>.fold(onSuccess: (D) -> R, onFailure: (E) -> R): R

Collapse both arms into one value.

Link copied to clipboard
fun <D, E> Result<D, E>.getOrNull(): D?
Link copied to clipboard
inline fun <D, E, R> Result<D, E>.map(transform: (D) -> R): Result<R, E>

Map the success value; failures pass through untouched.

Link copied to clipboard
inline fun <D, E, F> Result<D, E>.mapError(transform: (E) -> F): Result<D, F>

Map the error arm; successes pass through untouched.

Link copied to clipboard
inline fun <D, E> Result<D, E>.onFailure(action: (E) -> Unit): Result<D, E>

Run action on failure, returning the receiver for chaining.

Link copied to clipboard
inline fun <D, E> Result<D, E>.onSuccess(action: (D) -> Unit): Result<D, E>

Run action on success, returning the receiver for chaining.