directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <mcconn...@dpml.net>
Subject RE: [OT] How best to respond to null arguments?
Date Wed, 31 Aug 2005 19:41:18 GMT
 
> Question: How best to respond to null arguments?
> 
> Option #1: Ignore it and let a NPE result on its own
> Option #2: Test to see if arg is null early and throw a 
> descriptive NPE
> Option #3: Test to see if arg is null early and throw a 
> descriptive IAE
> 
> Which sounds best?

  #2 assuming we are taking about methods that assume a non-null value

  if( null == arg )
  {
     throw new NullPointerException( "arg" );
  }

Cheers, Steve.


> Alex
> 


Mime
View raw message