aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin
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 /src/net/java/sip/communicator/plugin
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 'src/net/java/sip/communicator/plugin')
-rw-r--r--src/net/java/sip/communicator/plugin/irccommands/command/Join.java9
-rw-r--r--src/net/java/sip/communicator/plugin/irccommands/command/Me.java9
-rw-r--r--src/net/java/sip/communicator/plugin/irccommands/command/Mode.java9
-rw-r--r--src/net/java/sip/communicator/plugin/irccommands/command/Msg.java9
-rw-r--r--src/net/java/sip/communicator/plugin/irccommands/command/Nick.java9
5 files changed, 45 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/plugin/irccommands/command/Join.java b/src/net/java/sip/communicator/plugin/irccommands/command/Join.java
index 20c9c72..d84d93b 100644
--- a/src/net/java/sip/communicator/plugin/irccommands/command/Join.java
+++ b/src/net/java/sip/communicator/plugin/irccommands/command/Join.java
@@ -76,4 +76,13 @@ public class Join implements Command
}
this.connection.getClient().joinChannel(channel, password);
}
+
+ /**
+ * Command usage instructions.
+ */
+ @Override
+ public String help()
+ {
+ return "Usage: /join <channel> [password]";
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/irccommands/command/Me.java b/src/net/java/sip/communicator/plugin/irccommands/command/Me.java
index cbbb869..c9f7c47 100644
--- a/src/net/java/sip/communicator/plugin/irccommands/command/Me.java
+++ b/src/net/java/sip/communicator/plugin/irccommands/command/Me.java
@@ -64,4 +64,13 @@ public class Me
}
this.connection.getClient().act(source, message);
}
+
+ /**
+ * Command usage instructions.
+ */
+ @Override
+ public String help()
+ {
+ return "Usage: /me <message>";
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java b/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java
index f738ae6..4fbae8e 100644
--- a/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java
+++ b/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java
@@ -66,4 +66,13 @@ public class Mode implements Command
}
this.connection.getClient().changeMode(source + " " + rawModeString);
}
+
+ /**
+ * Usage instructions.
+ */
+ @Override
+ public String help()
+ {
+ return "Usage: /mode <mode> [params ...]";
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java b/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java
index 7e10659..2e9ef6f 100644
--- a/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java
+++ b/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java
@@ -79,4 +79,13 @@ public class Msg implements Command
}
this.connection.getClient().message(target, message);
}
+
+ /**
+ * Usage instructions.
+ */
+ @Override
+ public String help()
+ {
+ return "Usage: /msg <user> <message>";
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java b/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java
index 39582cd..4216835 100644
--- a/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java
+++ b/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java
@@ -66,4 +66,13 @@ public class Nick implements Command
this.connection.getIdentityManager().setNick(newNick);
}
}
+
+ /**
+ * Usage instructions.
+ */
+ @Override
+ public String help()
+ {
+ return "Usage: /nick <new-nick>";
+ }
}