[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-cocoon-dev
Subject:    Re: [RT] Smarter Use of Exceptions
From:       Bertrand Delacretaz <bdelacretaz () apache ! org>
Date:       2005-09-30 5:42:41
Message-ID: 685fd6c9da1b5da6fe40801c2309cb13 () apache ! org
[Download RAW message or body]


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 
code...

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 
WhateverBaseExceptionYouLike
     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.

-Bertrand
["smime.p7s" (application/pkcs7-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic