Alpesh Vas
12/26/2019, 5:02 PMreturn
statement in the end even if we are throwing exception onFailure
fun<T> withRetryOnRateLimit(numOfRetries: Int = 10, func: () -> T): T {
repeat(numOfRetries) {
runCatching(func)
.onSuccess { return it }
.onFailure { throw it }
}
}
Simon Kågedal Reimer
12/26/2019, 5:21 PMStavFX
12/26/2019, 7:05 PMStavFX
12/26/2019, 7:09 PMreturn func()