I wrote Bill an example of why it is important to handle exceptions properly 
which I think is useful to the group at large, so I am copying it here too 
(hope that is ok Bill)

<snip>

> only find explicit handling useful when I need to do an action differently
> for each exception type.
>
> i.e.
>
> catch (SomeRecoverableException recoverable) { // do something }
> catch (Exception ex) { log.error("I'm fucked", ex); }

Right, but consider when your component with the above try/catch is nested 
inside of a larger component.  With this perspective it is usually a good 
idea to pass the buck... ie don't catch "I'm fucked", ex , just let it 
propagate to exception handler above it.

How about a real example then?  Ok,  take MainDeployer.deploy() (and 
undeploy()) which currently mask the exception thrown by the undelying 
methods and components which actually do the work.

If I am a client calling MainDeployer.deploy(url) I might want to perform some 
error handling if this operation fails.  If deploy() declared that it threw 
and Exception then I could write my client to gracefully handle this case.... 
in fact I would be forced to handle it or pass the buck (declare it to be 
thrown).

In the case of the client I might want to show a message to the user stating 
why the deployment failed or I might want to try a different url... whatever.

The point is that when you mask/eat exceptions you either make it impossible 
for the calling client to detect and recover, or you make it more difficult 
to determine.  In the deployer case you can call isDeployed after deploy and 
see if the deployment went through, but if it did not then the client is left 
with no reason or more detail to go on further.

Exceptions are very cool as when used properly they allow you to build simple 
components and clients with hierarchacle error handling and recovery.  
Consider the alternative of the shit style of error detection from c when an 
error is a non-zero return value and such... what a mess.

</snip>

--jason

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to