avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject RE: Useful error messages
Date Mon, 01 Sep 2003 22:48:40 GMT
> So I did some digging .....
> .. and in the James source for RepositoryManager I noticed the following:

We inherited that code from Cornerstone when we were told that in order to
fix bugs in the Cornerstone code, we needed to take that into our module so
that PeterD could remove it from Avalon.  Unfortunately, I don't think that
anyone on our side has really looked at it much.

  (a) we would be happy to give it back to you.
  (b) we would be happy for some suggestion(s).

> catch( final Exception e )
> {
> final String message = "Cannot find or init repository: " +
e.getMessage();
> getLogger().warn( message, e );
> throw new ServiceException("", message, e );
> }

Probably someone wanted to get the exception into that component's log, and
also to notify the caller.

> in AvalonMailStore (which is actually the "JamesMailStore") we have
> the following fragment

> catch (Exception e) {
>   if (getLogger().isWarnEnabled()) {
>     getLogger().warn( "Exception while creating repository:" +
e.getMessage(), e );
>   }
>   e.printStackTrace();
>   throw new ServiceException("","Cannot find or init repository", e);
> }

> As a rule I NEVER log an exception AND throw it.  The only time
> you need to log an exception is when you don't intent to throw it.

The printStackTrace ought to be canned, along with (almost) all uses of
RuntimeException.  We recently cleaned up a bunch of the latter.

The logging pattern is still an issue.  Logging to the component's log
and/or throwing the exception.  The former is reporting, the latter is
functional.  The latter *must* be done, so we are back to the issue of
wanting the exception to be logged in the right log.

> Finally, onto some Avalon concerns.

> (a) configuration exceptions would be more useful if they contained
>     the offending fragment
> (b) better specs are needed about component/container seperation
>     of responsibilities (e.g. who handled error reporting)

There is still the issue of locality, although this would not be apparent if
you only had one log file.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message