aboutsummaryrefslogtreecommitdiffstats
path: root/test/net
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-11-20 00:09:21 +0100
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-11-20 21:00:49 +0100
commit56e9c167bd78d444ec8e18e9f2a20959666bcb76 (patch)
tree827d6e2ebb9ee1ea8c36d692fd4bb23785affeb8 /test/net
parent3eb7b3da0e95ed3c063656534428c74b4580764f (diff)
downloadjitsi-56e9c167bd78d444ec8e18e9f2a20959666bcb76.zip
jitsi-56e9c167bd78d444ec8e18e9f2a20959666bcb76.tar.gz
jitsi-56e9c167bd78d444ec8e18e9f2a20959666bcb76.tar.bz2
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.
Diffstat (limited to 'test/net')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/CommandFactoryTest.java18
1 files changed, 18 insertions, 0 deletions
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