1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-26 07:20:09 +08:00

Optimize HeartbeatFailedException.toString: show information of its cause

This commit is contained in:
Him188 2021-06-16 03:09:21 +08:00
parent ab7c49a0d5
commit 45ba713f73
2 changed files with 6 additions and 3 deletions
mirai-core/src/commonMain/kotlin/network/impl/netty

View File

@ -12,6 +12,9 @@ package net.mamoe.mirai.internal.network.impl.netty
import net.mamoe.mirai.internal.network.handler.selector.NetworkException
internal class HeartbeatFailedException(
override val message: String?,
private val name: String, // kind of HB
override val cause: Throwable? = null
) : NetworkException(true)
) : NetworkException(true) {
override val message: String = "Exception in $name job"
override fun toString(): String = "HeartbeatFailedException: $name, cause=$cause"
}

View File

@ -355,7 +355,7 @@ internal open class NettyNetworkHandler(
private val heartbeatJobs =
context[HeartbeatScheduler].launchJobsIn(this@NettyNetworkHandler, this) { name, e ->
setState { StateClosed(HeartbeatFailedException("Exception in $name job", e)) }
setState { StateClosed(HeartbeatFailedException(name, e)) }
}
// we can also move them as observers if needed.