geirm       01/02/20 08:10:43

  Modified:    src/java/org/apache/velocity Template.java
  Log:
  Small change to merge() : throws an exception rather than just failing silently
  when we don't have a valid parsed template.
  
  This doesn't change the signature of the method, so user code shouldn't change,
  just the logic.  But this is better than before.  We may have a few iterations
  to sort out what we want to throw, but this is prollie the right direction.
  
  Revision  Changes    Path
  1.27      +22 -2     jakarta-velocity/src/java/org/apache/velocity/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/Template.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Template.java     2001/02/14 23:18:01     1.26
  +++ Template.java     2001/02/20 16:10:42     1.27
  @@ -87,7 +87,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
  - * @version $Id: Template.java,v 1.26 2001/02/14 23:18:01 dlr Exp $
  + * @version $Id: Template.java,v 1.27 2001/02/20 16:10:42 geirm Exp $
    */
   public class Template extends Resource
   {
  @@ -118,13 +118,24 @@
                       return true;
                   }    
               } 
  +            catch ( ParseException pex )
  +            {
  +                /*
  +                 *  there was a problem parsing the template
  +                 */                
  +            }
               finally 
               {
                   // Make sure to close the inputstream when we are done.
                   is.close();
               }
  +        }
  +        catch (Exception ignored) 
  +        {
  +            /*
  +             *  most likely, the resource wasn't found ?
  +             */
           }
  -        catch (Exception ignored) {}
      
           return false;            
       }
  @@ -207,8 +218,17 @@
               }
           }
           else
  +        {
               Runtime.error("Template.merge() failure. The document is null, " + 
                             "most likely due to parsing error.");
  +         
  +            /*
  +             *  lets throw a general exception here and see if anyone likes it
  +             */
  +
  +            throw new Exception("Template.merge() failure. The document is null, " 
+ 
  +                          "most likely due to parsing error.");
  +        }
       }
   }
   
  
  
  

Reply via email to