Skip to content

Failure

data class Failure<Failure>(val failure: Failure) : Outcome<Failure, Nothing> 

The latest known result of the operation was a failure, available as failure.

Constructors

Failure

constructor(failure: Failure)

Properties

failure

failure

failureOrNull

Returns Failure.failure, or null if this outcome is not a failure.

value

valueOrNull

Returns Success.value, or null if this outcome is not successful.

Functions

map

If this outcome is successful, replaces its value using transform.

If this outcome isn't successful, does nothing.

See also

  • mapFailure: Map the failure state instead of the success state.

mapFailure

If this outcome is failed, replaces its failure using transformFailure.

If this outcome isn't failed, does nothing.

See also

  • map: Map the success state instead of the failure state.

onFailure

inline fun <Failure> Outcome<Failure, *>.onFailure(block: (Failure) -> Unit)

Executes block if this outcome is a failure.

Otherwise, does nothing.

onSuccess

inline fun <Value> Outcome<*, Value>.onSuccess(block: (Value) -> Unit)

Executes block if this outcome is successful.

Otherwise, does nothing.

toEither

Converts an Outcome into a typed Either.

withProgress

Adds progress information to this outcome to make it a ProgressiveOutcome.