commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Caswell" <ste...@caswell.name>
Subject RE: [commons]NPE or IAE?
Date Wed, 21 Aug 2002 21:41:50 GMT
I understand your point. I agree that this is somewhat philosophical and
therefore the question could be argued until doomsday. Because of this,
IMHO the approach of treating them as two conditions is most flexible.
Those callers who believe they are separate conditions can handle them
separately. Those who believe they are the same can handle them the
same.  But at least throwing separate exceptions gives folks the choice.


Steven Caswell
steven@caswell.name
a.k.a Mungo Knotwise of Michel Delving
"One ring to rule them all, one ring to find them..."


> -----Original Message-----
> From: ola.berg@arkitema.se [mailto:ola.berg@arkitema.se] 
> Sent: Wednesday, August 21, 2002 4:24 PM
> To: commons-dev@jakarta.apache.org
> Subject: Re: [commons]NPE or IAE?
> 
> 
> >It has been my experience is that using different exceptions to 
> >indicate different conditions is preferred (and IMHO these are 
> >different conditions).  This presents the most flexibility to the
> >caller.
> 
> Are they really different? The role of the null object is 
> rather philosphical in nature. I can see that both views are valid.
> 
> IAE is thrown when you break the contract of a real parameter 
> to a method. NPE when you use a null pointer in an inappropriate way.
> 
> Contract states: non-null, non-negative Integer object. Throw 
> IAE for any violation.
> 
> or
> 
> Contract states: non-negative Integer object. Throw IAE for 
> any violation. However, since you must provide an object, it 
> is implicit that null is plain wrong. An illegal use of the 
> null pointer.
> 
> That we should have different exceptions for different 
> conditions, to that we all agree. Else, we could have used 
> Throwable all the way. My question is whether the conditions 
> really are different.
> 
> /O
> 
> --------------------
> ola.berg@arkitema.se
> 0733 - 99 99 17
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 
> 



--
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