Merge remote-tracking branch 'origin/master'

This commit is contained in:
Him188 2020-11-16 14:46:05 +08:00
commit 5e3ffafd5a
2 changed files with 13 additions and 1 deletions

View File

@ -18,6 +18,9 @@ import net.mamoe.mirai.console.command.descriptor.CommandArgumentParserException
* *
* [message] 将会发送给指令调用方. * [message] 将会发送给指令调用方.
* *
* 如果指令调用方是 [ConsoleCommandSender],
* 还会将 [cause], [suppressedExceptions] 发送给 [ConsoleCommandSender] (如果存在)
*
* @see CommandArgumentParserException * @see CommandArgumentParserException
*/ */
public open class IllegalCommandArgumentException : IllegalArgumentException { public open class IllegalCommandArgumentException : IllegalArgumentException {

View File

@ -62,7 +62,16 @@ internal fun startupConsoleThread() {
is Success -> { is Success -> {
} }
is IllegalArgument -> { is IllegalArgument -> {
result.exception.message?.let { consoleLogger.warning(it) } ?: kotlin.run { result.exception.message?.let { msg ->
val err = result.exception
if ((err.suppressed?.size ?: 0) != 0) {
// 该 IllegalArgument 错误还存在其他附加错误
consoleLogger.warning(result.exception)
} else {
consoleLogger.warning(msg)
err.cause?.let { consoleLogger.warning(it) }
}
} ?: kotlin.run {
consoleLogger.warning(result.exception) consoleLogger.warning(result.exception)
} }
} }