onFailureOrRethrow

inline fun <E : Throwable, T> Result<T>.onFailureOrRethrow(action: (Throwable) -> Unit): Result<T>

Like Result.onFailure, but rethrows exceptions of type E and invokes action for all others.

Extension function on Result.

Return

this Result

Parameters

action

the action to invoke on non-E failures

Type Parameters

E

the exception type to rethrow

T

the result type

Throws

if the failure is an instance of E