Failure

data class Failure<Error, Value>(error: Error) : Result<Error, Value>

A failed result of a computation

See also

Parameters

error

the problem that occurred

Constructors

Failure
Link copied to clipboard
fun <Error> Failure(error: Error)
the problem that occurred

Functions

andThen
Link copied to clipboard
fun <T> andThen(chain: (Value) -> Result<Error, T>): Result<Error, T>
Chain two computations togetherIf in a computation chain the result of one computation is needed as input for another computation, andThen is there to chain the computations together.
andThenError
Link copied to clipboard
fun <T> andThenError(chain: (Error) -> Result<T, Value>): Result<T, Value>
Chain two computations together for error recovery.
component1
Link copied to clipboard
operator fun component1(): Error
copy
Link copied to clipboard
fun copy(error: Error): Failure<Error, Value>
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
map
Link copied to clipboard
fun <T> map(transform: (Value) -> T): Result<Error, T>
Transform a successful result.
mapError
Link copied to clipboard
fun <T> mapError(transform: (Error) -> T): Result<T, Value>
Transform a failed result.
orThrowException
Link copied to clipboard
fun orThrowException(exceptionProducer: (Error) -> Exception): Value
Unwrap the result by throwing an Exception that can depend on the kind of failureif a computation was a Success, return that data.
toString
Link copied to clipboard
open override fun toString(): String
use
Link copied to clipboard
fun use(actOn: (Value) -> Unit): Result<Error, Value>
Use the data of a successful result.
useError
Link copied to clipboard
fun useError(actOn: (Error) -> Unit): Result<Error, Value>
Use the error of a failed result.
withDefault
Link copied to clipboard
fun withDefault(defaultValue: Value): Value
Unwrap the result by providing a default value.
fun withDefault(producer: (Error) -> Value): Value
Unwrap the result by providing a default value that can depend on the kind of failure.

Properties

error
Link copied to clipboard
val error: Error
the problem that occurred