Skip to content

Retry

hexagon_core / com.hexagonkt.helpers / retry

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.

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.

Exceptions

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

Return Callback's result if succeed.

Comments