1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

RequestsExecutor#executeUnsafe use do-while

This commit is contained in:
InsanusMokrassar 2019-03-12 10:50:06 +08:00
parent c167c556ae
commit 0cc03d757e

View File

@ -36,16 +36,13 @@ suspend fun <T: Any> RequestsExecutor.executeUnsafe(
retriesDelay: Long = 1000L retriesDelay: Long = 1000L
): T? { ): T? {
var leftRetries = retries var leftRetries = retries
while(true) { do {
try { try {
return execute(request) return execute(request)
} catch (e: RequestException) { } catch (e: RequestException) {
if (leftRetries > 0) { leftRetries--
leftRetries-- delay(retriesDelay)
delay(retriesDelay)
} else {
return null
}
} }
} } while(leftRetries >= 0)
return null
} }