geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dillon <ja...@coredevelopers.net>
Subject Re: [Error handling] NullPointer or IllegalArgument?
Date Thu, 14 Aug 2003 15:20:47 GMT
I change my mind, and I agree that we should never throw a NPE, but 
leave it as an exception the VM throws.

--jason


On Thursday, August 14, 2003, at 09:14  PM, Adrian Jackson wrote:

> Alex Blewitt wrote:
>> What I was saying is that NPE is an exception a programmer should
>> never throw, and if checked exceptions or other suitable exceptions
>> (IAE, NAE) don't allow, then throw RuntimeException instead of NPE.
>
> I'm strongly inclined to agree with *both* of you. Never throw
> RuntimeException. Never throw NullPointerException. If you find 
> yourself
> thinking it would be a good idea to throw either of these, then have a
> stiff drink and write a new exception class (not necessarily in that
> order).
>
> If either is acceptable, then it's probably the use of the
> NullPointerException, since the API documentation says "Applications
> should throw instances of this class to indicate other illegal uses of
> the null object", whereas for RuntimeException it says 
> "RuntimeException
> is the *superclass* of those exceptions that can be thrown during the
> normal operation of the Java Virtual Machine" (my emphasis).
>
> But really, neither is a good idea in my book, for the reasons that 
> Alex
> and Berin point out.
>
> And I'd also add my +1 to the idea that we should never have have a
> catch block for type Exception, except with very good reason.
>
> Adrian
>


Mime
View raw message