some fixes with reporting of errors

This commit is contained in:
Aikar
2017-04-29 00:45:24 -04:00
parent ae87e7440a
commit 60785ec00a
2 changed files with 17 additions and 13 deletions
@@ -102,7 +102,7 @@ public class CommandCompletions {
} catch (CommandCompletionTextLookupException ignored) {
// This should only happen if some other feedback error occured.
} catch (Exception e) {
ACFLog.exception(e);
command.handleException(sender, Lists.newArrayList(args), e);
}
// Something went wrong in lookup, fall back to input
return ImmutableList.of(input);
@@ -132,20 +132,24 @@ public class RegisteredCommand {
method.invoke(scope, passedArgs.values().toArray());
} catch (Exception e) {
if (e instanceof InvocationTargetException && e.getCause() instanceof InvalidCommandArgument) {
e = (Exception) e.getCause();
handleException(sender, args, e);
}
}
void handleException(CommandSender sender, List<String> args, Exception e) {
if (e instanceof InvocationTargetException && e.getCause() instanceof InvalidCommandArgument) {
e = (Exception) e.getCause();
}
if (e instanceof InvalidCommandArgument) {
if (e.getMessage() != null && !e.getMessage().isEmpty()) {
ACFUtil.sendMsg(sender, "&cError: " + e.getMessage());
}
if (e instanceof InvalidCommandArgument) {
if (e.getMessage() != null && !e.getMessage().isEmpty()) {
ACFUtil.sendMsg(sender, "&cError: " + e.getMessage());
}
if (((InvalidCommandArgument) e).showSyntax) {
scope.showSyntax(sender, this);
}
} else {
ACFUtil.sendMsg(sender, "&cI'm sorry, but there was an error performing this command.");
ACFLog.exception("Exception in command: " + command + " " + ACFUtil.join(args), e);
if (((InvalidCommandArgument) e).showSyntax) {
scope.showSyntax(sender, this);
}
} else {
ACFUtil.sendMsg(sender, "&cI'm sorry, but there was an error performing this command.");
ACFLog.exception("Exception in command: " + command + " " + ACFUtil.join(args), e);
}
}