repeatOnFailure

inline fun <R> repeatOnFailure(    times: Int,     onEachFailure: (Throwable) -> Unit = {},     action: (Int) -> R): Optional<R>

Executes the given action until getting of successful result specified number of times.

A zero-based index of current iteration is passed as a parameter to action.