commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang] NullArgumentException?
Date Sat, 29 Jun 2002 20:53:52 GMT
From: "Michael A. Smith" <mas@apache.org>
> On Sat, 29 Jun 2002, Stephen Colebourne wrote:
> > I would like to add a NullArgumentException class to the lang.exceptions
> > package.
> >
> > It would be a subclass of IllegalArgumentException.
> > It would be thrown when null is passed in as an argument when it
shouldn't
> > be.
> >
> > Any objections?
>
> That's what java.lang.NullPointerException is for.  "Applications should
> throw instances of this class to indicate other illegal uses of the null
> object."

I have to reasons for not wanting to use NullPointerException.
1) NullPointerException is an unplanned exception. Its thrown by the runtime
automatically, with no control over the error message. Overloading its use
for specifically validated exceptions is not good.
2) The Collection API doesn't allow NullPointerException to be thrown for a
rejection of null entry into a collection. It states it must be
IllegalArgumentException.

In both cases NullArgumentException would make life clearer.

Stephen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message