cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <>
Subject Re: [RT] Smarter Use of Exceptions
Date Fri, 30 Sep 2005 05:42:41 GMT
Hi Berin,

Thanks for your analysis, I fully agree with your conclusions.

> ...You have a much better idea of the problem when you see 
> ValidatorInitializationException as opposed to RuntimeException...

Yes, and it's so cheap to do, there's really no reason not to do it. 
But your report shows that we have a lot of work to do to fix our 

About exceptions, two patterns that I use frequently in my projects are

a) Inner exception in service interface

   public interface MarsExplorerService {
     static public class RobotFailedException extends 
WhateverBaseExceptionYouLike {

Which gives you a MarsExplorerService.RobotFailedException - the name 
says a lot already.

b) Exception marker interfaces

   class RemoteWebServiceUnavailableException extends 
     implements NetworkRelatedProblem, UserCanRetryLater

Where the interfaces can be used to classify the exceptions in error 
reporting, for example here to tell the user that they should retry the 
operation later with a reasonable chance of success.

Most often the interfaces here are markers only, they have no methods, 
but in some case methods can be useful to give additional information.

View raw message