mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-12 10:40:21 +08:00
Throws exception if fail
This commit is contained in:
parent
5e17449a93
commit
6b93ce3ccc
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user