catchOption

inline fun <R> catchOption(f: () -> Option<R>): Outcome<Throwable, R>(source)

Catches any exceptions thrown by the function and lifts the result into an Outcome. The Optional value will be preserved as Present or Absent accordingly.

Converts a function that throws an exception (throwable) and returns an Option into an Outcome

val outcome: Outcome<Throwable, Customer> = Outcome.catchOption {
val customer: Option<Customer> = maybeLoadCustomerOrThrow() // May or may not return a customer but throws on error
customer
}