tryRecover

inline fun <Ok : Any, ErrorIn : Any, ErrorOut : Any> Outcome<Ok, ErrorIn>.tryRecover(catch: (throwable: Throwable) -> Outcome<Ok, ErrorOut> = ::rethrow, failure: RaiseScope<ErrorOut>.(ErrorIn) -> Ok): Outcome<Ok, ErrorOut>

Transform failure into success.

This is the outcomeOf alternative to Outcome.recover.

outcomeOf { 4 } // Outcome.success(4)
.tryRecover { Unit } // No Change - Outcome.success(4)
.andThen { throw FileNotFoundException("test") } // Outcome.failure(FileNotFoundException("test"))
.tryRecover { 7 } // Outcome.success(7)

See also