ColibrioResult

sealed class ColibrioResult<out T>

Represents result of an operation. Can be either ColibrioResult.Success holding data of type T, or ColibrioResult.Error holding exception of type ColibrioException.

Inheritors

Types

Link copied to clipboard
data class Error(val exception: ColibrioException) : ColibrioResult<Nothing>

Represents an error result holding exception of type ColibrioException

Link copied to clipboard
data class Success<out T>(val data: T) : ColibrioResult<T>

Represents a successful operation result holding data of type T

Functions

Link copied to clipboard
fun getOrNull(): T?

Returns the encapsulated value if this ColibrioResult is ColibrioResult.Success or null if it is a ColibrioResult.Error

Link copied to clipboard
inline fun onError(action: (exception: ColibrioException) -> Unit): ColibrioResult<T>

Performs the given action on the encapsulated ColibrioException exception if this instance is ColibrioResult.Error. Returns the original ColibrioResult unchanged.

Link copied to clipboard
inline fun onSuccess(action: (T) -> Unit): ColibrioResult<T>

Performs the given action on the encapsulated data if this instance is ColibrioResult.Success. Returns the original ColibrioResult unchanged.