Outcome

sealed class Outcome<out T>

Represents the outcome of a repeated operation. This type is similar to a Result except it is a union type and has no flag for "success" since exceptional outcomes do not necessarily represent "failure".

Parameters

T

The type of non-exception result (if present).

Inheritors

Types

Link copied to clipboard
data class Exception(val attempts: Int, val exception: Throwable) : Outcome<Nothing>

An outcome that includes an exception.

Link copied to clipboard
data class Response<out T>(val attempts: Int, val response: T) : Outcome<T>

An outcome that includes a normal (i.e., non-exceptional) response.

Properties

Link copied to clipboard
abstract val attempts: Int

The number of attempts executed in order to reach the outcome. Starts at 1.

Inherited functions

Link copied to clipboard
fun <T> Outcome<T>.getOrThrow(): T

Gets the non-exceptional response in this outcome if it exists. Otherwise, throws the exception in this outcome.

Link copied to clipboard
fun <T> Outcome<T>.toResult(): <Error class: unknown class><T>

Convert an outcome to a Result