commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <>
Subject Re: [lang] StringUtils.containsOnly
Date Thu, 26 Sep 2002 19:46:24 GMT
Henri Yandell wrote:
> On Thu, 26 Sep 2002, Berin Loritsch wrote:
>>Steve Downey wrote:
>>>In any case, as I'm looking through right now, at least a few of the methods
>>>that claim not to thow NPEs, do.
>>My point is not to remove the throwing of exceptions, but to throw an
>>exception that is more meaningful.  The NPE is automatically thrown by
>>the system if you try to perform an action on a null reference--AKA the
>>C++ pointer error analogy.  That is why I prefer to use
>>IllegalArgumentExceptions instead.  We are not weakening preconditions,
>>but we are letting the user of the API know where the problem is (in
>>the arguments passed in).
> Didn't this come up before?

Dunno, I wasn't paying attention.

> And large amounts of Java threw NPE instead of
> IAE in this case?

That's a lemming argument if I ever heard it.  "All my friends are
jumping off a cliff, it must be the right thing to do!"  ;P

Seriously, my suggestion will help the users of the API to debug
their applications faster.  The fact that NPE is automatically
thrown by the JVM makes it confusing to track down the origination
of that exception.  At least with an IAE the user has a clue that
their code is at fault.

> Seem to recall deleting the thread last night while trimming my inbox...

You will probably delete this as well....


"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message