Skip to content

Commit

Permalink
Merge pull request #21 from unnamed/invalid-subcommand
Browse files Browse the repository at this point in the history
remove throws of InvalidSubCommandException
  • Loading branch information
FixedDev authored Apr 19, 2022
2 parents 9e9424b + 3d44b6d commit 2beb09e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,13 @@ public BukkitCommandManager(CommandManager delegate, String fallbackPrefix) {
return true;
});

this.getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, ex) -> {
BukkitCommandWrapper.sendMessageToSender(ex, namespace);

String label = namespace.getObject(String.class, "label");

throw new org.bukkit.command.CommandException("An internal parse exception occurred while executing the command " + label, ex);
});

ErrorHandler.ErrorConsumer<ArgumentException> commonArgumentExceptionConsumer = (namespace, ex) -> {
BukkitCommandWrapper.sendMessageToSender(ex, namespace);

return false;
};

this.getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(NoPermissionsException.class, (namespace, throwable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ public BungeeCommandManager(CommandManager commandManager, Plugin plugin) {
return false;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
String label = namespace.getObject(String.class, "label");
BungeeCommandWrapper.sendMessageToSender(e, namespace);

throw new CommandException("An internal parse exception occurred while executing the command " + label, e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
BungeeCommandWrapper.sendMessageToSender(e, namespace);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ public DiscordCommandManager(CommandManager commandManager, JDA client, String c
return true;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
MessageListener.sendMessage(namespace, e);

throw new CommandException("An internal parse exception occurred while executing the command", e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
MessageListener.sendMessage(namespace, e);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,14 @@ public VelocityCommandManager(ProxyServer proxyServer, CommandManager commandMan
return true;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
VelocityCommandWrapper.sendMessageToSender(e, namespace);

throw new CommandException("An internal parse exception occurred while executing the command", e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
VelocityCommandWrapper.sendMessageToSender(e, namespace);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down

0 comments on commit 2beb09e

Please sign in to comment.