From 56e9c167bd78d444ec8e18e9f2a20959666bcb76 Mon Sep 17 00:00:00 2001 From: Danny van Heumen Date: Thu, 20 Nov 2014 00:09:21 +0100 Subject: Improved error handling for commands. In case of bad command usage, throw an IllegalArgumentException. IllegalArgumentException will be caught and handled specially. Whenever IAE is thrown, it will be caught and command.help() will be called so that we can receive additional usage instructions. The error and the help information will be thrown inside a BadCommandInvocationException which will be handled by the appropriate OperationSet. In case of such an event, a system message will be fired with the usage instructions as to inform the user on how to use the command. Other exceptions will be logged as an error, as they are not expected and considered to be an implementation issue. --- .../impl/protocol/irc/CommandFactoryTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/net/java/sip/communicator/impl/protocol/irc/CommandFactoryTest.java b/test/net/java/sip/communicator/impl/protocol/irc/CommandFactoryTest.java index a47f0d4..18a88b8 100644 --- a/test/net/java/sip/communicator/impl/protocol/irc/CommandFactoryTest.java +++ b/test/net/java/sip/communicator/impl/protocol/irc/CommandFactoryTest.java @@ -73,6 +73,12 @@ public class CommandFactoryTest @Override public void execute(String source, String line) { + } + + @Override + public String help() + { + return null; }}; CommandFactory.registerCommand("test", Test.class); CommandFactory.registerCommand("foo", anotherType.getClass()); @@ -115,6 +121,12 @@ public class CommandFactoryTest public void execute(String source, String line) { } + + @Override + public String help() + { + return null; + } } public void testConstructionNullProvider() @@ -290,6 +302,12 @@ public class CommandFactoryTest public void execute(String source, String line) { } + + @Override + public String help() + { + return null; + } } public abstract static class BadImplementation implements Command -- cgit v1.1