Skip to content

Commit

Permalink
Be more specific about which command is missing when throwing an exce…
Browse files Browse the repository at this point in the history
…ption (#1125)
  • Loading branch information
gnodet authored Dec 10, 2024
1 parent 4276e1a commit f88c742
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ public Map<String, String> commandAliases() {
@SuppressWarnings("unchecked")
public <V extends Enum<V>> void rename(V command, String newName) {
if (nameCommand.containsKey(newName)) {
throw new IllegalArgumentException("Duplicate command name!");
throw new IllegalArgumentException("Duplicate command name '" + command + "'!");
} else if (!commandName.containsKey(command)) {
throw new IllegalArgumentException("Command does not exists!");
throw new IllegalArgumentException("Command '" + command + "' does not exists!");
}
commandName.put((T) command, newName);
doNameCommand();
}

public void alias(String alias, String command) {
if (!nameCommand.containsKey(command)) {
throw new IllegalArgumentException("Command does not exists!");
throw new IllegalArgumentException("Command '" + command + "' does not exists!");
}
aliasCommand.put(alias, command);
}
Expand All @@ -198,7 +198,7 @@ public T command(String name) {
if (nameCommand.containsKey(name)) {
out = nameCommand.get(name);
} else {
throw new IllegalArgumentException("Command does not exists!");
throw new IllegalArgumentException("Command '" + name + "' does not exists!");
}
return out;
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public <V extends Enum<V>> void rename(V command, String newName) {

public void alias(String alias, String command) {
if (!commandExecute.containsKey(command)) {
throw new IllegalArgumentException("Command does not exists!");
throw new IllegalArgumentException("Command '" + command + "' does not exists!");
}
aliasCommand.put(alias, command);
}
Expand Down

0 comments on commit f88c742

Please sign in to comment.