unwrapError

infix inline fun <Ok : Any, Error> Outcome<Ok, Error & Any>.unwrapError(faulter: (Ok) -> Error = { error("Outcome::unwrapError threw! Got: $this") }): Error

Attempt to unwrap Outcome into an Ok value.

val outcome: Outcome<String, Throwable> = ...
outcome.unwrapError() // errorOrThrow() (default behaviour)
outcome.unwrapError { null } // errorOrNull() (map Ok to null)
outcome.unwrapError { "$it" } // errorOrElse() (map Ok to fallback value)

Return

The error or the result of faulter.

See also

Throws