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


Reply via email to