From 88eebdc448a33c4d3e3a1fe876ac7f659fdce008 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Apr 2020 12:53:02 +0600 Subject: [PATCH] small optimization of updates polling exception handling --- .../extensions/api/updates/UpdatesPolling.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt index d39bd17fa4..9f18c87bc1 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt @@ -27,13 +27,9 @@ fun RequestsExecutor.startGettingOfUpdates( while (isActive) { handleSafely( { e -> - when (e) { - is HttpRequestTimeoutException -> exceptionsHandler ?.invoke(e) - is RequestException -> { - exceptionsHandler ?.invoke(e) - delay(1000L) - } - else -> exceptionsHandler ?.invoke(e) + exceptionsHandler ?.invoke(e) + if (e is RequestException) { + delay(1000L) } } ) {