You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Alex Blewitt <Al...@ioshq.com> on 2003/08/28 09:39:30 UTC
[Exception] New common exception type; InvalidArgumentException
I've created a new exception type for dealing with invalid arguments,
in o.a.g.common. It's basically the same as an
java.lang.IllegalArgumentException, except that it parameterises the
name/value of the argument.
I've also refactored the NullArgumentException to be a subtype of this,
since null is a special case of invalidity.
java.lang.IllegalArgumentException
+-- org.apache.geronimo.common.InvalidArgumentException
+-- org.apache.geronimo.common.NullArgumentException
You can create it with
void method(String name) {
NullArgumentException.checkForNull(name);
if (name has other problems)
throw new InvalidArgumentException("name",name);
}
or
void method(String name) {
NullArgumentException.checkForNull(name);
if (name has other problems)
throw new InvalidArgumentException("invalid
characters","name",name);
}
If it's just generally invalid, leave the reason blank and it will be
filled with a standard one. You should only use the reason where
there's a specific message to be given, and (ideally) should be a short
phrase that's suitable for later I18N :-)
Alex.
PS It's submitted as Geronimo-32, so when it's patched then it will be
there :-)
http://jira.codehaus.org/secure/ViewIssue.jspa?key=GERONIMO-32