Return-Path: Delivered-To: apmail-incubator-geronimo-dev-archive@incubator.apache.org Received: (qmail 66243 invoked by uid 500); 14 Aug 2003 17:46:35 -0000 Mailing-List: contact geronimo-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-dev@incubator.apache.org Received: (qmail 66229 invoked from network); 14 Aug 2003 17:46:35 -0000 Received: from dsl-217-155-97-60.zen.co.uk (HELO dsl-217-155-97-61.zen.co.uk) (217.155.97.60) by daedalus.apache.org with SMTP; 14 Aug 2003 17:46:35 -0000 Received: from apple.int.bandlem.com ([10.0.0.20] helo=ioshq.com) by dsl-217-155-97-61.zen.co.uk with esmtp (Exim 3.35 #1 (Debian)) id 19nMBL-00036L-00 for ; Thu, 14 Aug 2003 18:46:39 +0100 Date: Thu, 14 Aug 2003 18:46:41 +0100 Subject: Re: [Error handling] NullPointer or IllegalArgument? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Alex Blewitt To: geronimo-dev@incubator.apache.org Content-Transfer-Encoding: 7bit In-Reply-To: <3F3BC43C.5090001@apache.org> Message-Id: <434A4D18-CE7F-11D7-BB42-0003934D3EA4@ioshq.com> X-Mailer: Apple Mail (2.552) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Thursday, Aug 14, 2003, at 18:17 Europe/London, Berin Loritsch wrote: > Alex Blewitt wrote: > >> Why bother? RuntimeException has an argument to pass in the exception >> type to the superclass ... > Clarity. For the same reason that you complained about not being able > to differentiate between an NPE thrown by the system and one thrown by > our code. You can't differentiate a RuntimeException that holds an > IOException and one that holds a SQLException if all you use are > RuntimeExceptions. > > New exception types don't need to all be thought up in advance. You > can > create them as you find you have need. The question is, do you really need to be able to catch both exception types distinctly? You can instead use: } (catch RuntimeException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { } else if (cause instanceof SQLException) { } ... } I think this topic has had enough open airing in this mailing list now anyway, and whilst (hopefully) it's provoked a few thoughts, the general advice of not using RuntimeException and NullPointerException, and the benefits of using IllegalArgumentException and NullArgumentException have probably gone through, which was the original intent :-) I'd be happy to take the discussion off-line and further bash out a few points if you'd like to continue talking about it, though :-) Alex.