# replaceIfFailure

inline fun < T > Result < T >. replaceIfFailure (onException: ( Throwable ) -> T ): Result < T >(source)

Replaces a failed Result with a new value computed from the exception. If this Result is successful, it is returned as-is. If it represents a failure, the onException handler is called with the exception to compute a replacement value, which is then wrapped in a new Result.

#### Return

The original Result if successful, or a new Result containing the replacement value

#### Parameters

onException

A function that computes a replacement value from the caught exception

#### Type Parameters

T

The type of the successful value