From 7123f1e227feaa4c65f40acaa159ae0979432058 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 10 Sep 2020 09:05:08 +0800 Subject: [PATCH] Ignore CancellationException in MiraiConsole.coroutineContext[CoroutineExceptionHandler] --- .../mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt index 0d6abc78f..9bdf2d2ce 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleImplementationPure.kt @@ -74,6 +74,9 @@ class MiraiConsoleImplementationPure ) : MiraiConsoleImplementation, CoroutineScope by CoroutineScope( NamedSupervisorJob("MiraiConsoleImplementationPure") + CoroutineExceptionHandler { coroutineContext, throwable -> + if (throwable is CancellationException) { + return@CoroutineExceptionHandler + } val coroutineName = coroutineContext[CoroutineName]?.name ?: "" MiraiConsole.mainLogger.error("Exception in coroutine $coroutineName", throwable) }) {