1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +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
): T? {
var leftRetries = retries
while(true) {
do {
try {
return execute(request)
} catch (e: RequestException) {
if (leftRetries > 0) {
leftRetries--
delay(retriesDelay)
} else {
return null
}
leftRetries--
delay(retriesDelay)
}
}
} while(leftRetries >= 0)
return null
}