Return-Path: Delivered-To: apmail-incubator-geronimo-dev-archive@incubator.apache.org Received: (qmail 77984 invoked by uid 500); 14 Aug 2003 08:50:36 -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 77968 invoked from network); 14 Aug 2003 08:50:36 -0000 Received: from smtp013.mail.yahoo.com (216.136.173.57) by daedalus.apache.org with SMTP; 14 Aug 2003 08:50:36 -0000 Received: from 82-35-107-109.cable.ubr06.dals.blueyonder.co.uk (HELO yahoo.co.uk) (james?strachan@82.35.107.109 with plain) by smtp.mail.vip.sc5.yahoo.com with SMTP; 14 Aug 2003 08:50:49 -0000 Date: Thu, 14 Aug 2003 09:50:46 +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: James Strachan To: geronimo-dev@incubator.apache.org Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <65294EC6-CE34-11D7-B36D-000A959D0312@yahoo.co.uk> X-Mailer: Apple Mail (2.552) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I favour IAE myself as a guideline though wouldn't rule against NPE in some code. On Thursday, August 14, 2003, at 09:25 am, Alex Blewitt wrote: > On Thursday, Aug 14, 2003, at 07:57 Europe/London, James Strachan > wrote: > >> On Thursday, August 14, 2003, at 06:31 am, Aaron Mulder wrote: >> >>> Maas, >>> >>> egarding this particular patch, I'd prefer that we don't actually >>> add "null" to the list of DeploymentFactories, even if it's passed >>> as an >>> argument to DeploymentFactoryManager.registerDeploymentFactory(). >>> That's >>> silly, we should just ignore a null. >> >> Failing fast with silly arguments is a good idea - e.g. throw an >> IllegalArgumentException or NullPointerException. > > I've never liked the idea of a method throwing an NPE when passed a > null argument. A bunch of the Java data structures do this, and I've > had pains when they do so. > > An NPE (to me) means a coding bug, usually requiring a lot of hard > work figuring out where it came from and why it exists > > An IllegalArgumentException means that a method has been passed a > wrong value (i.e. value out of range, string in wrong format, null > value passed when arg was required), and usually has some kind of > error message associated with it. > > Go on, tell me which you'd prefer to see in the logs: > > [Exception] NullPointerException > > [Exception] IllegalArgumentException: address must not be null > > Alex. > > PS Votes for saying 'never throw NPEs in methods; use IAE instead?' in > the coding standards? > > James ------- http://radio.weblogs.com/0112098/