You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Felix Knecht <fe...@otego.com> on 2010/03/03 10:12:44 UTC

Exception logging inconsistent ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all

I came across following log/exception [1]:

<snip>
String msg = "RuleId " + ruleId + " not found in ruleId to schema name
map!";
LOG.warn( msg );
throw new NamingException( msg );
</snip>

Wouldn't it be more consistent when logging an error instead of a
warning when afterwards an exception is thrown?

If wanted I can fix when I come across such codings.

Felix

[1]
shared-ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java
[line 103 ff]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuOKAwACgkQ2lZVCB08qHHlVwCdE0+3OcgpNg+bSQKv68BZpUGI
vq0AnieJlkYvLJfKs1oy1fJ7fB7FFOBm
=v+UR
-----END PGP SIGNATURE-----

Re: Exception logging inconsistent ?

Posted by Felix Knecht <fe...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/03/10 10:12, Felix Knecht wrote:
> Hi all
> 
> I came across following log/exception [1]:
> 
> <snip>
> String msg = "RuleId " + ruleId + " not found in ruleId to schema name
> map!";
> LOG.warn( msg );
> throw new NamingException( msg );
> </snip>
> 
> Wouldn't it be more consistent when logging an error instead of a
> warning when afterwards an exception is thrown?

There are even more, this time logging a debug message [line 142 ff]:

String msg = "DITStructureRule for ruleId " + ruleId + " does not exist!";
LOG.debug( msg );
throw new NamingException( msg );

> 
> If wanted I can fix when I come across such codings.
> 
> Felix
> 
> [1]
> shared-ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java
> [line 103 ff]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuOKNEACgkQ2lZVCB08qHEnQwCfTypdzKZOcmIA4gH6opNNNT/V
q8QAnA3FGzf/YdhgH40IUJMCXMeEIA4B
=qaLM
-----END PGP SIGNATURE-----

Re: Exception logging inconsistent ?

Posted by Felix Knecht <fe...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>> Wouldn't it be more consistent when logging an error instead of a
>> warning when afterwards an exception is thrown?
>>    
> It's not obvious. Sometime, we throw an exception because it's teh way
> to know that something went wrong, but we catch this exception at a
> higher level and go on. Typically, this is what we do when searching
> elements in the schema. The fact that the element is not present is not
> an error, from the server POV, but it is from the user POV. Now, we
> generally log a debug in this case because we don't want the server logs
> to be swamped with errors due to a user trying to get data which does
> not exist.

I see, thanks for explanation. I keep it as is.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuOLmAACgkQ2lZVCB08qHE3igCdE3Tkv+omeZ4e3Q60ZW8ODD9r
Y10An0lT0XIhyOi5/1XuhcR3heZLRD/g
=Tn/4
-----END PGP SIGNATURE-----

Re: Exception logging inconsistent ?

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 3/3/10 10:12 AM, Felix Knecht wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all
>
> I came across following log/exception [1]:
>
> <snip>
> String msg = "RuleId " + ruleId + " not found in ruleId to schema name
> map!";
> LOG.warn( msg );
> throw new NamingException( msg );
> </snip>
>
> Wouldn't it be more consistent when logging an error instead of a
> warning when afterwards an exception is thrown?
>    
It's not obvious. Sometime, we throw an exception because it's teh way 
to know that something went wrong, but we catch this exception at a 
higher level and go on. Typically, this is what we do when searching 
elements in the schema. The fact that the element is not present is not 
an error, from the server POV, but it is from the user POV. Now, we 
generally log a debug in this case because we don't want the server logs 
to be swamped with errors due to a user trying to get data which does 
not exist.

Of course, we could have code that without exception,  but it would have 
been much harder when the method called is supposed to return a result.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com