From 4ef349d0ac2ba5f5631b6b38ea2d0e119dcb4f5f Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 Oct 2022 15:39:02 +0100 Subject: [PATCH] Add CoroutineExceptionHandler to LoginChannelHandler Signed-off-by: Graham --- .../org/openrs2/game/net/login/LoginChannelHandler.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt b/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt index 5e7dd6e0..17c17efb 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt @@ -16,6 +16,7 @@ import io.netty.handler.codec.http.HttpRequestDecoder import io.netty.handler.codec.http.HttpResponseEncoder import io.netty.handler.codec.string.StringDecoder import io.netty.handler.timeout.IdleStateEvent +import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.cancel @@ -66,7 +67,11 @@ public class LoginChannelHandler @Inject constructor( private var serverKey = 0L override fun handlerAdded(ctx: ChannelHandlerContext) { - scope = CoroutineScope(ctx.executor().asCoroutineDispatcher()) + val exceptionHandler = CoroutineExceptionHandler { _, ex -> + ctx.fireExceptionCaught(ex) + } + + scope = CoroutineScope(ctx.executor().asCoroutineDispatcher() + exceptionHandler) } override fun handlerRemoved(ctx: ChannelHandlerContext) {