Commit 6b93ce3c authored by Him188's avatar Him188

Throws exception if fail

parent 5e17449a
......@@ -60,15 +60,20 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
fun tryReinitializeNetworkHandler(
cause: Throwable?
): Job = launch {
var lastFailedException: Throwable? = null
repeat(configuration.reconnectionRetryTimes) {
try {
reinitializeNetworkHandler(cause)
logger.info("Reconnected successfully")
return@launch
} catch (e: LoginFailedException) {
} catch (e: Throwable) {
lastFailedException = e
delay(configuration.reconnectPeriodMillis)
}
}
if (lastFailedException != null) {
throw lastFailedException!!
}
}
private suspend fun reinitializeNetworkHandler(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment