From 1b1f3bbcbe0e6b10d711fd704b2b2b073661672e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 25 Oct 2021 15:04:59 +0100 Subject: [PATCH] Fix #1375 --- .../platform/PlatformCommandManager.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 36fda3df1..d07b4d805 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -112,6 +112,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; +import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.command.CommandArgParser; @@ -910,11 +911,22 @@ public final class PlatformCommandManager { try { suggestions = commandManager.getSuggestions(access, argStrings); } catch (Throwable t) { // catch errors which are *not* command exceptions generated by parsers/suggesters - if (!(t instanceof CommandException)) { - LOGGER.error("Unexpected error occurred while generating suggestions for input: {}", arguments, t); - return; + if (!(t instanceof InputParseException) && !(t instanceof CommandException)) { + Throwable cause = t; + // These exceptions can be very nested, and should not be printed as they are not an actual error. + boolean printError = true; + while ((cause = cause.getCause()) != null) { + if (cause instanceof InputParseException || cause instanceof CommandException) { + printError = false; + break; + } + } + if (printError) { + LOGGER.error("Unexpected error occurred while generating suggestions for input: {}", arguments, t); + return; + } } - throw t; + return; } event.setSuggestions(suggestions.stream()