Ignore CancellationException in MiraiConsole.coroutineContext[CoroutineExceptionHandler]

This commit is contained in:
Him188 2020-09-10 09:05:08 +08:00
parent 335299275b
commit 7123f1e227

View File

@ -74,6 +74,9 @@ class MiraiConsoleImplementationPure
) : MiraiConsoleImplementation, CoroutineScope by CoroutineScope( ) : MiraiConsoleImplementation, CoroutineScope by CoroutineScope(
NamedSupervisorJob("MiraiConsoleImplementationPure") + NamedSupervisorJob("MiraiConsoleImplementationPure") +
CoroutineExceptionHandler { coroutineContext, throwable -> CoroutineExceptionHandler { coroutineContext, throwable ->
if (throwable is CancellationException) {
return@CoroutineExceptionHandler
}
val coroutineName = coroutineContext[CoroutineName]?.name ?: "<unnamed>" val coroutineName = coroutineContext[CoroutineName]?.name ?: "<unnamed>"
MiraiConsole.mainLogger.error("Exception in coroutine $coroutineName", throwable) MiraiConsole.mainLogger.error("Exception in coroutine $coroutineName", throwable)
}) { }) {