sdk-common / com.tomtom.online.sdk.common.functional / Try / recoverWith

recoverWith

abstract fun recoverWith(@NonNull function: (in Throwable!) -> Try<out T>!): Try<T>!

Applies the given function if this is a Failure, otherwise returns a Success if this is a Success. This is like a Try#flatMap(Function1) for an exception.

Parameters

function - (in Throwable!) -> Try<out T>!: Function that will be used to recover from the exception if this is a Failure.

Return
Try<T>!: instance of Success if the recovery was successful, a Failure otherwise.