mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 03:16:05 +08:00
Do not wrap exception into ISE on reaching max attempts
This commit is contained in:
parent
a38f24cbe5
commit
fc477e0122
@ -76,10 +76,7 @@ internal abstract class AbstractKeepAliveNetworkHandlerSelector<H : NetworkHandl
|
||||
|
||||
private tailrec suspend fun runImpl(): H {
|
||||
if (attempted >= maxAttempts) {
|
||||
throw IllegalStateException(
|
||||
"Failed to resume instance. Maximum attempts reached.",
|
||||
exceptionCollector.getLast()
|
||||
)
|
||||
throw exceptionCollector.getLast() ?: MaxAttemptsReachedException(null)
|
||||
}
|
||||
yield() // Avoid endless recursion.
|
||||
val current = getCurrentInstanceOrNull()
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.network.handler.selector
|
||||
|
||||
internal data class MaxAttemptsReachedException(
|
||||
override val cause: Throwable?
|
||||
) : IllegalStateException("Failed to resume instance. Maximum attempts reached.")
|
@ -40,6 +40,7 @@ internal interface NetworkHandlerSelector<H : NetworkHandler> {
|
||||
* Returned [H] can be in [NetworkHandler.State.OK] only (but it may happen that the state changed just after returning from this function).
|
||||
*
|
||||
* This function may throw exceptions, which would be propagated to the original caller of [SelectorNetworkHandler.resumeConnection].
|
||||
* @throws MaxAttemptsReachedException
|
||||
*/
|
||||
suspend fun awaitResumeInstance(): H
|
||||
}
|
Loading…
Reference in New Issue
Block a user