commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wer...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz AttainGoalTag.java
Date Mon, 15 Jul 2002 16:18:15 GMT
werken      2002/07/15 09:18:15

  Modified:    jelly/src/java/org/apache/commons/jelly JellyException.java
               jelly/src/java/org/apache/commons/jelly/impl TagScript.java
               jelly/src/java/org/apache/commons/jelly/tags/werkz
                        AttainGoalTag.java
  Log:
  Cleaning up werkz/jelly exception wrapping/unwrapping.
  Added special case for InvocationTargetException unwrapping.
  
  Revision  Changes    Path
  1.9       +16 -6     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyException.java
  
  Index: JellyException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyException.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JellyException.java	9 Jul 2002 21:13:07 -0000	1.8
  +++ JellyException.java	15 Jul 2002 16:18:15 -0000	1.9
  @@ -111,7 +111,7 @@
       }
       
       public JellyException(String reason, Throwable cause, String fileName, String elementName,
int columnNumber, int lineNumber) {
  -        super(reason);
  +        super( (reason==null?cause.getClass().getName():reason) );
           this.cause = cause;
           this.fileName = fileName;
           this.elementName = elementName;
  @@ -215,4 +215,14 @@
               cause.printStackTrace(s);
           }
       }
  +
  +    /*
  +    public void printStackTrace() {
  +        super.printStackTrace();
  +        if ( cause != null ) {
  +            System.err.println("Root cause");
  +            cause.printStackTrace();
  +        }
  +    }
  +    */
   }
  
  
  
  1.16      +38 -5     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
  
  Index: TagScript.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TagScript.java	15 Jul 2002 11:22:27 -0000	1.15
  +++ TagScript.java	15 Jul 2002 16:18:15 -0000	1.16
  @@ -65,6 +65,7 @@
   import java.beans.Introspector;
   import java.beans.PropertyDescriptor;
   import java.lang.reflect.Method;
  +import java.lang.reflect.InvocationTargetException;
   import java.io.Writer;
   import java.util.ArrayList;
   import java.util.HashMap;
  @@ -292,6 +293,22 @@
        */
       protected void handleException(Exception e) throws Exception {
           log.error( "Caught exception: " + e, e );
  +
  +        if ( e instanceof JellyException )
  +        {
  +            e.fillInStackTrace();
  +            throw e;
  +        }
  +
  +        if ( e instanceof InvocationTargetException)
  +        {
  +            throw new JellyException( ((InvocationTargetException)e).getTargetException(),
  +                                      fileName,
  +                                      elementName,
  +                                      columnNumber,
  +                                      lineNumber );
  +        }
  +
           throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); 
          
       }
       
  @@ -308,6 +325,22 @@
        * Creates a new Jelly exception, adorning it with location information
        */
       protected JellyException createJellyException(String reason, Exception cause) {
  +        if ( cause instanceof JellyException )
  +        {
  +            return (JellyException) cause;
  +        }
  +
  +        if ( cause instanceof InvocationTargetException)
  +        {
  +            return new JellyException( 
  +                reason,
  +                ((InvocationTargetException)cause).getTargetException(),
  +                fileName,
  +                elementName,
  +                columnNumber,
  +                lineNumber);
  +        }
  +
           return new JellyException( 
               reason, cause, fileName, elementName, columnNumber, lineNumber
           );
  
  
  
  1.5       +28 -3     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainGoalTag.java
  
  Index: AttainGoalTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainGoalTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AttainGoalTag.java	26 Jun 2002 09:24:35 -0000	1.4
  +++ AttainGoalTag.java	15 Jul 2002 16:18:15 -0000	1.5
  @@ -61,6 +61,7 @@
   import com.werken.werkz.Goal;
   import com.werken.werkz.Session;
   import com.werken.werkz.Project;
  +import com.werken.werkz.UnattainableGoalException;
   
   import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.XMLOutput;
  @@ -109,8 +110,32 @@
   
           invokeBody(output);
   
  -        project.attainGoal( getName(),
  -                            session );
  +        try
  +        {
  +            project.attainGoal( getName(),
  +                                session );
  +        }
  +        catch (UnattainableGoalException e)
  +        {
  +            Throwable root = e.getRootCause();
  +
  +            if ( root != null )
  +            {
  +                if ( root instanceof JellyException )
  +                {
  +                    throw (JellyException) root;
  +                }
  +                if ( root instanceof UnattainableGoalException )
  +                {
  +                    throw e;
  +                }
  +            }
  +            else
  +            {
  +                e.fillInStackTrace();
  +                throw e;
  +            }
  +        }
       }
       
       // Properties
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message