mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Do not throw exception from PacketCodec but log with CoroutineExceptionHandler
This commit is contained in:
parent
b90f86258c
commit
5aae46218f
@ -51,6 +51,10 @@ internal interface PacketCodec {
|
||||
}
|
||||
}
|
||||
|
||||
internal data class ExceptionInPacketCodecException(
|
||||
override val cause: Throwable,
|
||||
) : IllegalStateException("Exception in PacketCodec.", cause)
|
||||
|
||||
internal class OicqDecodingException(
|
||||
val targetException: Throwable
|
||||
) : RuntimeException(
|
||||
|
@ -56,9 +56,12 @@ internal open class NettyNetworkHandler(
|
||||
protected open fun handleExceptionInDecoding(error: Throwable) {
|
||||
if (error is OicqDecodingException) {
|
||||
if (error.targetException is EOFException) return
|
||||
throw error.targetException
|
||||
}
|
||||
throw error
|
||||
|
||||
coroutineContext[CoroutineExceptionHandler]!!.handleException(
|
||||
coroutineContext,
|
||||
ExceptionInPacketCodecException(error.unwrap<OicqDecodingException>())
|
||||
)
|
||||
}
|
||||
|
||||
protected open fun handlePipelineException(ctx: ChannelHandlerContext, error: Throwable) {
|
||||
|
Loading…
Reference in New Issue
Block a user