From 1340a07cc41be35d3cfcf6c3d44947cebab904d4 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sat, 7 Dec 2024 14:03:33 +0100 Subject: [PATCH] Be more specific about which command is missing when throwing an exception --- .../jline/console/impl/AbstractCommandRegistry.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/console/src/main/java/org/jline/console/impl/AbstractCommandRegistry.java b/console/src/main/java/org/jline/console/impl/AbstractCommandRegistry.java index 610015aba..673513f85 100644 --- a/console/src/main/java/org/jline/console/impl/AbstractCommandRegistry.java +++ b/console/src/main/java/org/jline/console/impl/AbstractCommandRegistry.java @@ -162,9 +162,9 @@ public Map commandAliases() { @SuppressWarnings("unchecked") public > 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(); @@ -172,7 +172,7 @@ public > void rename(V command, String newName) { 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); } @@ -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; } @@ -230,7 +230,7 @@ public > 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); }