directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <>
Subject Re: [OT] How best to respond to null arguments?
Date Thu, 01 Sep 2005 16:35:08 GMT
On Fri, 2005-09-02 at 00:09 +0800, Niclas Hedhman wrote:
> Even better if the offending caller's identity is extracted, reformatted for 
> human consumption and placed as the argument in the exception thrown;
> java.lang.IllegalArgumentException: The class org.niclas.hedhman.SomeCode 
> passed a null argument for the third parameter ("history") on line 263, to 
> the computeHealthStatus() method in class

Using a good pattern in conjonction with slf4j could help a lot :

if (arg == null)
    log.error("the third parameter ('history') is null");
    throw new IAE(<a message>);

As you can exhibit the method name and the line number with %C and %L,
it increases the message correctness.


View raw message