Error

data class Error<T, E : KthException>(val error: E) : KthResult<T, E>

Result returned in case of Error.

Constructors

Link copied to clipboard
constructor(error: E)

Properties

Link copied to clipboard
val error: E

The error.

Functions

Link copied to clipboard
open fun onError(block: (E) -> Unit): KthResult<T, E>

Executes a block of code when the result is Error, otherwise does nothing.

Link copied to clipboard
open fun onSuccess(block: (T) -> Unit): KthResult<T, E>

Executes a block of code when the result is Success, otherwise does nothing.

Link copied to clipboard
open fun orElse(other: T): T

Returns the result value in case of Success, otherwise returns the other value.

Link copied to clipboard
open fun orElseGet(block: (E) -> T): T

Returns the result value in case of Success, otherwise returns the result of the block of code.

Link copied to clipboard
open fun orNull(): T?

Returns the result value in case of Success, otherwise returns null.

Link copied to clipboard
open fun orThrow(): T

Returns the result value in case of Success, otherwise throws an exception related to the error.