From 42a4c844e11ba1150a2b0779fc4336b83754e213 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 10 Sep 2020 09:04:06 +0800 Subject: [PATCH] Ignore CancellationException on stop --- .../net/mamoe/mirai/console/command/BuiltInCommands.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt index 78a17cd26..d653c9263 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt @@ -9,10 +9,7 @@ package net.mamoe.mirai.console.command -import kotlinx.coroutines.CoroutineName -import kotlinx.coroutines.cancel -import kotlinx.coroutines.cancelAndJoin -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import net.mamoe.mirai.Bot @@ -122,8 +119,9 @@ public object BuiltInCommands { ignoreException { sendMessage("mirai-console stopped successfully.") } }, onFailure = { + if (it is CancellationException) return@fold @OptIn(ConsoleInternalAPI::class) - MiraiConsole.mainLogger.error(it) + MiraiConsole.mainLogger.error("Exception in stop", it) ignoreException { sendMessage( it.localizedMessage ?: it.message ?: it.toString()