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