recover

inline fun <VALUE> Result<VALUE>.recover(transform: (Throwable) -> VALUE): Result<VALUE>

Returns the encapsulated result of the given transform function applied to encapsulated exception if this instance represents Error or the original encapsulated value if it is Success.

If Error.error is CancellationException then this error is rethrown.

Note, that an exception thrown by transform function is rethrown by this function. See recoverCatching for an alternative that encapsulates exceptions.