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:
parent
c167c556ae
commit
0cc03d757e
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user