You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2001/09/07 20:11:22 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/directive Include.java

geirm       01/09/07 11:11:22

  Modified:    src/java/org/apache/velocity/runtime/directive Include.java
  Log:
  Correctly propogate RNFE's to top
  
  Revision  Changes    Path
  1.22      +19 -4     jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java
  
  Index: Include.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Include.java	2001/08/07 21:57:56	1.21
  +++ Include.java	2001/09/07 18:11:22	1.22
  @@ -1,3 +1,4 @@
  +
   package org.apache.velocity.runtime.directive;
   
   /*
  @@ -66,6 +67,7 @@
   import org.apache.velocity.util.StringUtils;
   
   import org.apache.velocity.exception.MethodInvocationException;
  +import org.apache.velocity.exception.ResourceNotFoundException;
   
   /**
    * Pluggable directive that handles the #include() statement in VTL. 
  @@ -100,7 +102,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:kav@kav.dk">Kasper Nielsen</a>
  - * @version $Id: Include.java,v 1.21 2001/08/07 21:57:56 geirm Exp $
  + * @version $Id: Include.java,v 1.22 2001/09/07 18:11:22 geirm Exp $
    */
   public class Include extends Directive
   {
  @@ -150,7 +152,7 @@
        */
       public boolean render(InternalContextAdapter context, 
                              Writer writer, Node node)
  -        throws IOException, MethodInvocationException
  +        throws IOException, MethodInvocationException, ResourceNotFoundException
       {
           /*
            *  get our arguments and check them
  @@ -195,7 +197,7 @@
        */
       private boolean renderOutput( Node node, InternalContextAdapter context, 
                                     Writer writer )
  -        throws IOException, MethodInvocationException
  +        throws IOException, MethodInvocationException, ResourceNotFoundException
       {
           String arg = "";
           
  @@ -244,9 +246,22 @@
   
               resource = rsvc.getContent(arg, encoding);
           }
  +        catch ( ResourceNotFoundException rnfe )
  +        {
  +       		/*
  +       		 * the arg wasn't found.  Note it and throw
  +       		 */
  +       		 
  +        	rsvc.error("#include(): cannot find resource '" + arg + "', called from template " 
  +        		+ context.getCurrentTemplateName() + " at (" + getLine() + ", " + getColumn() + ")" );       	
  +        	throw rnfe;
  +        }
  +
           catch (Exception e)
           {
  -            rsvc.error("#include : cannot find " + arg + " template");
  +        	rsvc.error("#include(): arg = '" + arg + "',  called from template " 
  +        		+ context.getCurrentTemplateName() + " at (" + getLine() + ", " + getColumn() 
  +        		+ ") : " + e);       	
           }            
           
           if ( resource == null )