directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: [OT] How best to respond to null arguments?
Date Thu, 01 Sep 2005 17:38:13 GMT
On Friday 02 September 2005 00:35, Emmanuel Lecharny wrote:
> 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.

Very true, and my idea is to have a small utility that does the "trick" that 
Log4J does, i.e. fill in the stack, grab the second top element for "where 
was this detected" and the next element for "where was that called from"...

The other thing, personally(!), I don't think any "library" (definition of 
what makes a library is a different story) should utilize logging frameworks 
at all, be very conservative with any external output and instead rely on 
exceptions and events to communicate such things. For instance, pass all such 
"log data" to a router class, where the user can register one or more Loggers 
if she wants it.

Cheers
Niclas

Mime
View raw message