onFailureOrRethrow

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

Runs action on failure unless the failure is of type E, in which case it is rethrown.

Useful when a Result may still contain a CancellationException (e.g. after raw runCatching).