retry

fun <T> retry(times: Int, delay: Long, block: () -> T): T

Execute a lambda until no exception is thrown or a number of times is reached.

Return

Callback's result if succeeded.

Parameters

times

Number of times to try to execute the callback. Must be greater than 0.

delay

Milliseconds to wait to next execution if there was an error. Must be 0 or greater.

block

Code to be executed.

Throws

if the callback didn't succeed in the given times.