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)) {
is Success -> {
}
is IllegalArgument -> {
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)
}
is IllegalArgument -> { // user wouldn't want stacktrace for a parser error unless it is in debugging mode (to do).
val message = result.exception.message
if (message != null) {
consoleLogger.warning(message)
} else consoleLogger.warning(result.exception)
}
is ExecutionFailed -> {
consoleLogger.error(result.exception)