Error

data class Error(throwable: Throwable) : Result<Nothing>

Indicates an error state.

Constructors

Error
Link copied to clipboard
fun Error(message: String)

Indicates an error state.

Error
Link copied to clipboard
fun Error(message: String, cause: Throwable)

Indicates an error state.

Error
Link copied to clipboard
fun Error(message: String, error: Result.Error)

Indicates an error state.

Error
Link copied to clipboard
fun Error(throwable: Throwable)

Functions

mapData
Link copied to clipboard
fun <S> mapData(dataMapper: (Nothing) -> S): Result<S>

Maps the type T to type S.

mapError
Link copied to clipboard
fun mapError(mapper: (Throwable) -> Exception): Result<Nothing>
mapToUnit
Link copied to clipboard
fun mapToUnit(): Result<Unit>

Maps the type T to Unit.

onError
Link copied to clipboard
fun onError(callback: (Throwable) -> Unit): Result<Nothing>

Convenience method to listen for Error.

onSuccess
Link copied to clipboard
fun onSuccess(callback: (Nothing) -> Unit): Result<Nothing>

Convenience method to listen for Success.

toString
Link copied to clipboard
open override fun toString(): String

Properties

dataOrNull
Link copied to clipboard
val dataOrNull: Nothing?

Convenience property to directly get the Success.data of T if this Result is a Success or null otherwise.

throwable
Link copied to clipboard
val throwable: Throwable

the throwable of this error

throwableOrNull
Link copied to clipboard
val throwableOrNull: Throwable?

Convenience property to directly get the Error.throwable if this Result is an Error or null otherwise