mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Ignore CancellationException on stop
This commit is contained in:
parent
3c64b99553
commit
42a4c844e1
@ -9,10 +9,7 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineName
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.cancel
|
|
||||||
import kotlinx.coroutines.cancelAndJoin
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
@ -122,8 +119,9 @@ public object BuiltInCommands {
|
|||||||
ignoreException<EventCancelledException> { sendMessage("mirai-console stopped successfully.") }
|
ignoreException<EventCancelledException> { sendMessage("mirai-console stopped successfully.") }
|
||||||
},
|
},
|
||||||
onFailure = {
|
onFailure = {
|
||||||
|
if (it is CancellationException) return@fold
|
||||||
@OptIn(ConsoleInternalAPI::class)
|
@OptIn(ConsoleInternalAPI::class)
|
||||||
MiraiConsole.mainLogger.error(it)
|
MiraiConsole.mainLogger.error("Exception in stop", it)
|
||||||
ignoreException<EventCancelledException> {
|
ignoreException<EventCancelledException> {
|
||||||
sendMessage(
|
sendMessage(
|
||||||
it.localizedMessage ?: it.message ?: it.toString()
|
it.localizedMessage ?: it.message ?: it.toString()
|
||||||
|
Loading…
Reference in New Issue
Block a user