diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-11-20 21:36:06 +0100 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2014-11-20 21:36:06 +0100 |
commit | d8b7c44361830a8ca1300e826053f1479ffe437e (patch) | |
tree | c002c375609b3691d4f3511da04effb1cab2d22f /src/net/java/sip/communicator/plugin | |
parent | 56e9c167bd78d444ec8e18e9f2a20959666bcb76 (diff) | |
download | jitsi-d8b7c44361830a8ca1300e826053f1479ffe437e.zip jitsi-d8b7c44361830a8ca1300e826053f1479ffe437e.tar.gz jitsi-d8b7c44361830a8ca1300e826053f1479ffe437e.tar.bz2 |
Modified commands to make use of IllegalArgumentException handling.
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
5 files changed, 9 insertions, 7 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 d84d93b..a8a5113 100644 --- a/src/net/java/sip/communicator/plugin/irccommands/command/Join.java +++ b/src/net/java/sip/communicator/plugin/irccommands/command/Join.java @@ -53,7 +53,7 @@ public class Join implements Command { if (line.length() < END_OF_COMMAND_PREFIX) { - return; + throw new IllegalArgumentException("Missing channel to join."); } final String part = line.substring(END_OF_COMMAND_PREFIX); final String channel; 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 c9f7c47..1b6625f 100644 --- a/src/net/java/sip/communicator/plugin/irccommands/command/Me.java +++ b/src/net/java/sip/communicator/plugin/irccommands/command/Me.java @@ -54,7 +54,7 @@ public class Me { if (line.length() < END_OF_ME_COMMAND_PREFIX) { - return; + throw new IllegalArgumentException("The message is missing."); } final String message = line.substring(4); if (message.isEmpty()) 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 4fbae8e..5d75c60 100644 --- a/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java +++ b/src/net/java/sip/communicator/plugin/irccommands/command/Mode.java @@ -55,7 +55,7 @@ public class Mode implements Command { // does not currently support requesting (and displaying) mode query // results. - return; + throw new IllegalArgumentException("Mode parameters are missing."); } final String rawModeString = line.substring(END_OF_MODE_COMMAND_PREFIX); 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 2e9ef6f..c3441c4 100644 --- a/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java +++ b/src/net/java/sip/communicator/plugin/irccommands/command/Msg.java @@ -53,7 +53,8 @@ public class Msg implements Command { if (line.length() < END_OF_MSG_COMMAND_PREFIX) { - return; + throw new IllegalArgumentException( + "Both target nick and message are missing."); } final String part = line.substring(5); int endOfNick = part.indexOf(' '); 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 4216835..4d9c853 100644 --- a/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java +++ b/src/net/java/sip/communicator/plugin/irccommands/command/Nick.java @@ -15,6 +15,7 @@ import net.java.sip.communicator.impl.protocol.irc.*; */ public class Nick implements Command { + private static final int END_OF_COMMAND_PREFIX_INDEX = 6; /** * Instance of the IRC connection. */ @@ -45,12 +46,12 @@ public class Nick implements Command @Override public void execute(final String source, final String line) { - if (line.length() <= 5) + if (line.length() <= END_OF_COMMAND_PREFIX_INDEX) { // no name parameter available, so nothing to do here - return; + throw new IllegalArgumentException("New nick name is missing."); } - final String part = line.substring(6); + final String part = line.substring(END_OF_COMMAND_PREFIX_INDEX); final String newNick; int indexOfSep = part.indexOf(' '); if (indexOfSep == -1) |