geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Blewitt <Alex.Blew...@ioshq.com>
Subject [Exception] New common exception type; InvalidArgumentException
Date Thu, 28 Aug 2003 07:39:30 GMT
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


Mime
View raw message