# Failure

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

Failed result with error error.

#### Parameters

E

Type of the error. It has to extend Throwable.

## Constructors

Failure
Link copied to clipboard
constructor(error: E)

## Properties

error
Link copied to clipboard
val error: E
isFailure
Link copied to clipboard
val isFailure: Boolean

True if the result is an error, false otherwise.

isSuccess
Link copied to clipboard
val isSuccess: Boolean

True if the result was successful, false otherwise.

## Functions

error
Link copied to clipboard
open override fun error(): E

Returns the error associated. In case of Success, error will be null.

flatMap
Link copied to clipboard
fun <V, U, E : Throwable> Either<V, E>.flatMap(f: (V) -> Either<U, E>): Either<U, E>

Converts the Either value according to f function.

flatMapError
Link copied to clipboard
fun <V, E : Throwable, X : Throwable> Either<V, E>.flatMapError(f: (E) -> Either<V, X>): Either<V, X>

Converts the Either error according to f function.

map
Link copied to clipboard
fun <V, U, E : Throwable> Either<V, E>.map(f: (V) -> U): Either<U, E>

Converts the Either value according to f function.

mapError
Link copied to clipboard
fun <V, E : Throwable, X : Throwable> Either<V, E>.mapError(f: (E) -> X): Either<V, X>

Converts the Either error according to f function.

onFailure
Link copied to clipboard
fun <V, E : Throwable> Either<V, E>.onFailure(f: (E) -> Unit)

Calls the function f with a specific error when Either is failure.

onSuccess
Link copied to clipboard
fun <V, E : Throwable> Either<V, E>.onSuccess(f: (V) -> Unit)

Calls the function f with a specific value when Either is successful.

value
Link copied to clipboard
open override fun value(): Nothing?

Returns the value associated. In case of Failure, value will be null.