On Thursday, August 14, 2003, at 10:30 am, Jason Dillon wrote:

Note on further checking - NPE is not an IAE. They're both RuntimeExceptions but thats about it. Sorry Jason I think you're mistaken - but it would have been nice though.

Huh? Was there another Jason on this thread...

DOH - I misread your mail (that'll teach me for giving up caffeine) - I thought you implied NPE extends IAE. Sorry Jason! You really said this...


org.apache.geronimo.common.NullArgumentException extends IAE and handles the formatting of the message too, so you can:

throw new NullArgumentException("address");

So we can all just throw NullArgumentException instead - cool.

To make life a little simpler if you're writing a method I've added a wee helper method which checks for null & throws the exception if required...

public void doSomething(Foo foo, Bar bar) {
        NullArgumentException.checkForNull("foo", foo);
        NullArgumentException.checkForNull("bar", bar);

        ...
}

James
-------
http://radio.weblogs.com/0112098/



Reply via email to