sealed class Result<out V, out E>
Used to represent whether a sdk operation was successful or encountered an error
V - Type of the value returned for a successful operation
data class Failure<out E> : Result<Nothing, E>
Operation failed and returned an associated Exception |
|
data class Success<out V> : Result<V, Nothing>
Operation was successful and return a associated value of type V |
val isError: Boolean
Returns true if the result is a failure |
|
val isSuccess: Boolean
Returns true if the result is a success |
fun getErrorOrNull(): E?
Returns the associated exception error of type E if operation encountered a failure, otherwise null |
|
fun getOrThrow(): V
Returns the associated value of type V if operation was successful, otherwise throws the failure exception |
|
fun getValueOrNull(): V?
Returns the associated value of type V if operation was successful, otherwise null |
fun <E> failure(error: E): Failure<E>
Helper to build a Failure operation |
|
fun <V> of(function: () -> V): Result<V, Exception>
Result built from the result of the function |
|
fun <V> success(value: V): Success<V>
Helper to build a Success operation |
data class Failure<out E> : Result<Nothing, E>
Operation failed and returned an associated Exception |
|
data class Success<out V> : Result<V, Nothing>
Operation was successful and return a associated value of type V |