Don't show stacktrace for IllegalArgument failure

This commit is contained in:
Him188 2020-11-16 15:42:14 +08:00
parent 0021b0e927
commit b7b9149a06

View File

@ -71,19 +71,11 @@ internal fun startupConsoleThread() {
when (val result = ConsoleCommandSender.executeCommand(next)) { when (val result = ConsoleCommandSender.executeCommand(next)) {
is Success -> { is Success -> {
} }
is IllegalArgument -> { is IllegalArgument -> { // user wouldn't want stacktrace for a parser error unless it is in debugging mode (to do).
result.exception.message?.let { msg -> val message = result.exception.message
val err = result.exception if (message != null) {
if ((err.suppressed?.size ?: 0) != 0) { consoleLogger.warning(message)
// 该 IllegalArgument 错误还存在其他附加错误 } else consoleLogger.warning(result.exception)
consoleLogger.warning(result.exception)
} else {
consoleLogger.warning(msg)
err.cause?.let { consoleLogger.warning(it) }
}
} ?: kotlin.run {
consoleLogger.warning(result.exception)
}
} }
is ExecutionFailed -> { is ExecutionFailed -> {
consoleLogger.error(result.exception) consoleLogger.error(result.exception)