You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Thorsten Scherler <th...@wyona.com> on 2006/08/04 17:51:03 UTC

Re: svn commit: r428728 - /forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java

El vie, 04-08-2006 a las 15:31 +0100, Ross Gardler escribió:
> thorsten@apache.org wrote:
> > Author: thorsten
> > Date: Fri Aug  4 07:01:27 2006
> > New Revision: 428728
> > 
> > URL: http://svn.apache.org/viewvc?rev=428728&view=rev
> > Log:
> > Throwing the exception instead of swollowing it. Forgot to add this in the first place.
> > 
> > Modified:
> >     forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
> > 
> > Modified: forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
> > URL: http://svn.apache.org/viewvc/forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java?rev=428728&r1=428727&r2=428728&view=diff
> > ==============================================================================
> > --- forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java (original)
> > +++ forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java Fri Aug  4 07:01:27 2006
> > @@ -177,6 +177,7 @@
> >          }
> >          } catch (Exception e) {
> >          	getLogger().error("Opps, something went wrong.",e);
> > +        	throw new Exception("Opps, something went wrong.",e);
> >          }
> 
> Better, but ...
> 
> Why wrap it in a new exception?
> 
> We should be doing one of the following:
> 
> 1) prevent the exception occurring

+1

> 2) trap the exception and deal with it

if needed (not possible with 1.) and if it brings benefit (not only
logging reason).

"The Java Language Specification states that "an exception will be
thrown when semantic constraints are violated," which basically implies
that an exception throws in situations that are ordinarily not possible
or in the event of a gross violation of acceptable behavior. " see the
javaworld article. 

> 3) let the exception pass through and deal with it later

ok, you mean remove the catch clause. 

Agree is better.

> 4) wrap the exception in a *more* meaningful exception (either checked 
> or unchecked) and rethrow it

Agree.

My order would be 1.,4.,3.,2. 

> 
> What was happening was 2) with respect to FileNotFound 

that is violating 1.

> and 3) with 
> respect to all other exceptions.

agree.

> 
> You've modified it so that we are doing 2) with respect to FileNotFound, 
> that's good, but you have also wrapped the exception in a *less* 
> meaningful one for example you could be going from IOException to Exception.
> 
> What added benefit do we get from this catch and rethrow?

nothing, I have removed it now.

How does it look like?

salu2

> 
> Ross
> 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org