Failure

data class Failure(val error: DatabaseException) : DataResult<Nothing>

Represents an error during operation.

Constructors

Link copied to clipboard
constructor(error: DatabaseException)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun <R, T : R> DataResult<T>.getOrElse(onFailure: (Throwable) -> R): R

Returns the value if the result is Success, or computes a default value from the error if it is Failure.

Link copied to clipboard

Returns the value if the result is Success, or throws an exception if it is Failure.

Link copied to clipboard
inline fun <T, R> DataResult<T>.map(transform: (T) -> R): DataResult<R>

Transforms the value inside DataResult.Success, leaving DataResult.Failure unchanged.

Link copied to clipboard

Executes an action if the result is Failure, without modifying the original error.

Link copied to clipboard
fun <T> DataResult<T>.onSuccess(action: (T) -> Unit): DataResult<T>

Executes an action if the result is Success, without modifying the original value.