velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/directive Directive.java Foreach.java Parse.java
Date Fri, 07 Sep 2001 05:03:49 GMT
geirm       01/09/06 22:03:49

  Modified:    src/java/org/apache/velocity/runtime/directive
                        Directive.java Foreach.java Parse.java
  Log:
  Support for exception propogation to app level for RNFE and PEE
  exceptions from a #parse().
  
  Revision  Changes    Path
  1.16      +7 -4      jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java
  
  Index: Directive.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Directive.java	2001/08/07 21:57:56	1.15
  +++ Directive.java	2001/09/07 05:03:49	1.16
  @@ -63,13 +63,15 @@
   import org.apache.velocity.runtime.parser.node.Node;
   
   import org.apache.velocity.exception.MethodInvocationException;
  +import org.apache.velocity.exception.ParseErrorException;
  +import org.apache.velocity.exception.ResourceNotFoundException;
   
   
   /**
    * Base class for all directives used in Velocity.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: Directive.java,v 1.15 2001/08/07 21:57:56 geirm Exp $ 
  + * @version $Id: Directive.java,v 1.16 2001/09/07 05:03:49 geirm Exp $ 
    */
   public abstract class Directive implements DirectiveConstants,Cloneable
   {
  @@ -121,6 +123,7 @@
        * How this directive is to be rendered 
        */
       public abstract boolean render( InternalContextAdapter context, 
  -                                    Writer writer, Node node )
  -        throws IOException, MethodInvocationException;
  -}   
  +                                    Writer writer, Node node )       
  +           throws IOException, ResourceNotFoundException, ParseErrorException, 
  +                MethodInvocationException;
  + }   
  
  
  
  1.38      +5 -2      jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
  
  Index: Foreach.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Foreach.java	2001/08/07 21:57:56	1.37
  +++ Foreach.java	2001/09/07 05:03:49	1.38
  @@ -77,6 +77,8 @@
   import org.apache.velocity.runtime.parser.node.Node;
   
   import org.apache.velocity.exception.MethodInvocationException;
  +import org.apache.velocity.exception.ParseErrorException;
  +import org.apache.velocity.exception.ResourceNotFoundException;
   
   import org.apache.velocity.util.introspection.Introspector;
   import org.apache.velocity.util.introspection.IntrospectionCacheData;
  @@ -87,7 +89,7 @@
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  - * @version $Id: Foreach.java,v 1.37 2001/08/07 21:57:56 geirm Exp $
  + * @version $Id: Foreach.java,v 1.38 2001/09/07 05:03:49 geirm Exp $
    */
   public class Foreach extends Directive
   {
  @@ -313,7 +315,8 @@
        */
       public boolean render( InternalContextAdapter context, 
                              Writer writer, Node node )
  -        throws IOException,  MethodInvocationException
  +        throws IOException,  MethodInvocationException, ResourceNotFoundException,
  +        	ParseErrorException
       {        
           /*
            *  do our introspection to see what our collection is
  
  
  
  1.22      +28 -4     jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java
  
  Index: Parse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Parse.java	2001/08/07 21:57:56	1.21
  +++ Parse.java	2001/09/07 05:03:49	1.22
  @@ -68,6 +68,8 @@
   import org.apache.velocity.util.StringUtils;
   
   import org.apache.velocity.exception.MethodInvocationException;
  +import org.apache.velocity.exception.ParseErrorException;
  +import org.apache.velocity.exception.ResourceNotFoundException;
   
   /**
    * Pluggable directive that handles the #parse() statement in VTL. 
  @@ -87,7 +89,7 @@
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
  - * @version $Id: Parse.java,v 1.21 2001/08/07 21:57:56 geirm Exp $
  + * @version $Id: Parse.java,v 1.22 2001/09/07 05:03:49 geirm Exp $
    */
   public class Parse extends Directive
   {
  @@ -116,7 +118,7 @@
        */
       public boolean render( InternalContextAdapter context, 
                              Writer writer, Node node)
  -        throws IOException, MethodInvocationException
  +        throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException
       {
           /*
            *  did we get an argument?
  @@ -193,9 +195,31 @@
           {
               t = rsvc.getTemplate( arg, encoding );   
           }
  -        catch ( Exception e)
  +        catch ( ResourceNotFoundException rnfe )
           {
  -            rsvc.error("#parse : cannot find " + arg + " template!");
  +       		/*
  +       		 * the arg wasn't found.  Note it and throw
  +       		 */
  +       		 
  +        	rsvc.error("#parse(): cannot find template '" + arg + "', called from template
" 
  +        		+ context.getCurrentTemplateName() + " at (" + getLine() + ", " + getColumn()
+ ")" );       	
  +        	throw rnfe;
  +        }
  +        catch ( ParseErrorException pee )
  +        {
  +        	/*
  +        	 * the arg was found, but didn't parse - syntax error
  +        	 *  note it and throw
  +        	 */
  +
  +        	rsvc.error("#parse(): syntax error in #parse()-ed template '" + arg + "', called
from template " 
  +        		+ context.getCurrentTemplateName() + " at (" + getLine() + ", " + getColumn()
+ ")" );    
  +        		
  +        	throw pee;
  +        } 
  +        catch ( Exception e)
  +        {	
  +        	rsvc.error("#parse() : arg = " + arg + ".  Exception : " + e);
               return false;
           }
       
  
  
  

Mime
View raw message