You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/20 00:00:34 UTC

svn commit: r687177 - in /velocity/engine/trunk: src/java/org/apache/velocity/app/ src/java/org/apache/velocity/context/ src/java/org/apache/velocity/runtime/ src/java/org/apache/velocity/runtime/directive/ src/java/org/apache/velocity/runtime/log/ src...

Author: nbubna
Date: Tue Aug 19 15:00:32 2008
New Revision: 687177

URL: http://svn.apache.org/viewvc?rev=687177&view=rev
Log:
VELOCITY-467 throw more exceptions, log fewer errors

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java
    velocity/engine/trunk/src/java/org/apache/velocity/app/VelocityEngine.java
    velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Include.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/log/LogManager.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PutExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ContentResource.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Introspector.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/misc/TestLogChute.java
    velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp
    velocity/engine/trunk/test/macroforwarddefine/macros.vm

Modified: velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java Tue Aug 19 15:00:32 2008
@@ -34,6 +34,7 @@
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeSingleton;
 import org.apache.velocity.runtime.log.Log;
@@ -293,8 +294,9 @@
         }
         catch (IOException ioe)
         {
-            getLog().error("Velocity.invokeVelocimacro() failed", ioe);
-            return false;
+            String msg = "Velocity.invokeVelocimacro("+vmName+") failed";
+            getLog().error(msg, ioe);
+            throw new VelocityException(msg, ioe);
         }
     }
 
@@ -351,9 +353,10 @@
 
         if ( template == null )
         {
-            getLog().error("Velocity.mergeTemplate() was unable to load template '"
-                           + templateName + "'");
-            return false;
+            String msg = "Velocity.mergeTemplate() was unable to load template '"
+                           + templateName + "'";
+            getLog().error(msg);
+            throw new ResourceNotFoundException(msg);
         }
         else
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/app/VelocityEngine.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/app/VelocityEngine.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/app/VelocityEngine.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/app/VelocityEngine.java Tue Aug 19 15:00:32 2008
@@ -371,9 +371,10 @@
 
         if ( template == null )
         {
-            getLog().error("Velocity.mergeTemplate() was unable to load template '"
-                           + templateName + "'");
-            return false;
+            String msg = "VelocityEngine.mergeTemplate() was unable to load template '"
+                           + templateName + "'";
+            getLog().error(msg);
+            throw new ResourceNotFoundException(msg);
         }
         else
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java Tue Aug 19 15:00:32 2008
@@ -26,6 +26,7 @@
 
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.ParserTreeConstants;
 import org.apache.velocity.runtime.parser.node.ASTReference;
@@ -274,7 +275,9 @@
                 }
                 catch (Exception e)
                 {
-                    rsvc.getLog().error("ProxyVMContext.get() : error rendering reference", e);
+                    String msg = "ProxyVMContext.get() : error rendering reference";
+                    rsvc.getLog().error(msg, e);
+                    throw new VelocityException(msg, e);
                 }
             }
             else

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Tue Aug 19 15:00:32 2008
@@ -47,6 +47,7 @@
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.directive.Directive;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.runtime.log.LogManager;
@@ -383,7 +384,9 @@
         }
         catch (IOException ioe)
         {
-            log.error("Cannot get Velocity Runtime default properties!", ioe);
+            String msg = "Cannot get Velocity Runtime default properties!";
+            log.error(msg, ioe);
+            throw new RuntimeException(msg, ioe);
         }
         finally
         {
@@ -396,7 +399,9 @@
             }
             catch (IOException ioe)
             {
-                log.error("Cannot close Velocity Runtime default properties!", ioe);
+                String msg = "Cannot close Velocity Runtime default properties!";
+                log.error(msg, ioe);
+                throw new RuntimeException(msg, ioe);
             }
         }
     }
@@ -802,7 +807,9 @@
         }
         catch (IOException ioe)
         {
-            log.error("Error while loading directive properties!", ioe);
+            String msg = "Error while loading directive properties!";
+            log.error(msg, ioe);
+            throw new RuntimeException(msg, ioe);
         }
         finally
         {
@@ -815,7 +822,9 @@
             }
             catch (IOException ioe)
             {
-                log.error("Cannot close directive properties!", ioe);
+                String msg = "Cannot close directive properties!";
+                log.error(msg, ioe);
+                throw new RuntimeException(msg, ioe);
             }
         }
 
@@ -898,8 +907,10 @@
             }
             else
             {
-                log.error(directiveClass + " does not implement "
-                    + Directive.class.getName() + "; it cannot be loaded.");
+                String msg = directiveClass + " does not implement "
+                    + Directive.class.getName() + "; it cannot be loaded.";
+                log.error(msg);
+                throw new VelocityException(msg);
             }
         }
         // The ugly threesome:  ClassNotFoundException,
@@ -907,7 +918,9 @@
         // Ignore Findbugs complaint for now.
         catch (Exception e)
         {
-            log.error("Failed to load Directive: " + directiveClass, e);
+            String msg = "Failed to load Directive: " + directiveClass;
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 
@@ -1219,8 +1232,9 @@
             }
             catch(Exception e)
             {
-                getLog().error("RuntimeInstance.render(): init exception for tag = "
-                               + logTag, e);
+                String msg = "RuntimeInstance.render(): init exception for tag = "+logTag;
+                getLog().error(msg, e);
+                throw new VelocityException(msg, e);
             }
 
             /*
@@ -1261,8 +1275,9 @@
         /* check necessary parameters */
         if (vmName == null || context == null || writer == null)
         {
-            getLog().error("RuntimeInstance.invokeVelocimacro() : invalid call : vmName, context, and writer must not be null");
-            return false;
+            String msg = "RuntimeInstance.invokeVelocimacro() : invalid call : vmName, context, and writer must not be null";
+            getLog().error(msg);
+            throw new NullPointerException(msg);
         }
 
         /* handle easily corrected parameters */
@@ -1278,9 +1293,10 @@
         /* does the VM exist? */
         if (!isVelocimacro(vmName, logTag))
         {
-            getLog().error("RuntimeInstance.invokeVelocimacro() : VM '" + vmName
-                           + "' is not registered.");
-            return false;
+            String msg = "RuntimeInstance.invokeVelocimacro() : VM '" + vmName
+                         + "' is not registered.";
+            getLog().error(msg);
+            throw new VelocityException(msg);
         }
 
         /* now just create the VM call, and use evaluate */

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java Tue Aug 19 15:00:32 2008
@@ -28,6 +28,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.velocity.Template;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.directive.Directive;
 import org.apache.velocity.runtime.directive.Macro;
 import org.apache.velocity.runtime.directive.VelocimacroProxy;
@@ -213,7 +214,9 @@
                          }
                          catch (Exception e)
                          {
-                             log.error(true, "Velocimacro : Error using VM library : " + lib, e);
+                             String msg = "Velocimacro : Error using VM library : " + lib;
+                             log.error(true, msg, e);
+                             throw new VelocityException(msg, e);
                          }
 
                          log.trace("VM library registration complete.");
@@ -360,7 +363,7 @@
             }
             msg += " argument was null";
             log.error(msg);
-            return false;
+            throw new NullPointerException(msg);
         }
 
         /*
@@ -443,7 +446,7 @@
             }
             msg += " argument was null";
             log.error(msg);
-            return false;
+            throw new NullPointerException(msg);
         }
 
         /*
@@ -492,7 +495,7 @@
          */
         if (!addNewAllowed)
         {
-            log.error("VM addition rejected : "+name+" : inline VMs not allowed.");
+            log.warn("VM addition rejected : "+name+" : inline VMs not allowed.");
             return false;
         }
 
@@ -630,7 +633,9 @@
                     }
                     catch (Exception e)
                     {
-                        log.error(true, "Velocimacro : Error using VM library : " + lib, e);
+                        String msg = "Velocimacro : Error using VM library : " + lib;
+                        log.error(true, msg, e);
+                        throw new VelocityException(msg, e);
                     }
 
                     vp = vmManager.get(vmName, sourceTemplate, renderingTemplate);

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java Tue Aug 19 15:00:32 2008
@@ -31,6 +31,7 @@
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.node.ASTReference;
@@ -473,7 +474,9 @@
         }
         catch(Exception ee)
         {
-            rsvc.getLog().error("Error getting iterator for #foreach", ee);
+            String msg = "Error getting iterator for #foreach";
+            rsvc.getLog().error(msg, ee);
+            throw new VelocityException(msg, ee);
         }
 
         if (i == null)

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Include.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Include.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Include.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Include.java Tue Aug 19 15:00:32 2008
@@ -27,6 +27,7 @@
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.ParserTreeConstants;
@@ -156,10 +157,13 @@
             }
             else
             {
-                rsvc.getLog().error("#include() invalid argument type: "
-                                    + n.toString());
+                String msg = "invalid #include() argument type [line "+getLine()+
+                             ", column "+getColumn()+", template "+
+                             context.getCurrentTemplateName()+"]: "+n.toString();
+                rsvc.getLog().error(msg);
                 outputErrorToStream( writer, "error with arg " + i
                     + " please see log.");
+                throw new VelocityException(msg);
             }
         }
 
@@ -245,10 +249,12 @@
         }
         catch (Exception e)
         {
-            rsvc.getLog().error("#include(): arg = '" + arg +
-                                "', called from template " +
-                                context.getCurrentTemplateName() + " at (" +
-                                getLine() + ", " + getColumn() + ')', e);
+            String msg = "#include(): arg = '" + arg +
+                        "', called from template " +
+                        context.getCurrentTemplateName() + " at (" +
+                        getLine() + ", " + getColumn() + ')';
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java Tue Aug 19 15:00:32 2008
@@ -30,6 +30,7 @@
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.parser.node.Node;
 import org.apache.velocity.runtime.parser.node.SimpleNode;
@@ -212,8 +213,9 @@
         }
         catch ( Exception e)
         {
-            rsvc.getLog().error("#parse() : arg = " + arg + '.', e);
-            return false;
+            String msg = "#parse() : arg = " + arg + '.';
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
         /**
@@ -263,8 +265,9 @@
 
         catch ( Exception e )
         {
-            rsvc.getLog().error("Exception rendering #parse(" + arg + ')', e);
-            return false;
+            String msg = "Exception rendering #parse(" + arg + ')';
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
         finally
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java Tue Aug 19 15:00:32 2008
@@ -28,6 +28,7 @@
 import org.apache.velocity.exception.MacroOverflowException;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.node.ASTDirective;
@@ -206,6 +207,7 @@
             vmc.pushCurrentMacroName(macroName);
             nodeTree.render(vmc, writer);
             vmc.popCurrentMacroName();
+            return true;
         }
         catch (MethodInvocationException e)
         {
@@ -217,10 +219,10 @@
         }
         catch (Exception e)
         {
-            rsvc.getLog().error("VelocimacroProxy.render() : exception VM = #" + macroName + "()",
-                    e);
+            String msg = "VelocimacroProxy.render() : exception VM = #" + macroName + "()";
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
-        return true;
     }
 
     /**
@@ -284,7 +286,7 @@
                 parent = parent.jjtGetParent();
             }
 
-            String errormsg = "VM #" + macroName + ": error : too "
+            String msg = "VM #" + macroName + ": too "
                     + ((getNumArgs() > i) ? "few" : "many") + " arguments to macro. Wanted "
                     + getNumArgs() + " got " + i;
 
@@ -293,11 +295,11 @@
                 /**
                  * indicate col/line assuming it starts at 0 - this will be corrected one call up
                  */
-                throw new TemplateInitException(errormsg, context.getCurrentTemplateName(), 0, 0);
+                throw new TemplateInitException(msg, context.getCurrentTemplateName(), 0, 0);
             }
             else
             {
-                rsvc.getLog().error(errormsg);
+                rsvc.getLog().debug(msg);
                 return;
             }
         }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/log/LogManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/log/LogManager.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/log/LogManager.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/log/LogManager.java Tue Aug 19 15:00:32 2008
@@ -22,7 +22,7 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.util.ClassUtils;
@@ -83,7 +83,9 @@
                 }
                 catch (Exception e)
                 {
-                    log.error("Could not init runtime.log.logsystem " + o, e);
+                    String msg = "Could not init runtime.log.logsystem " + o;
+                    log.error(msg, e);
+                    throw new VelocityException(msg, e);
                 }
             }
             // then check for a LogSystem
@@ -100,12 +102,16 @@
                 }
                 catch (Exception e)
                 {
-                    log.error("Could not init runtime.log.logsystem " + o, e);
+                    String msg = "Could not init runtime.log.logsystem " + o;
+                    log.error(msg, e);
+                    throw new VelocityException(msg, e);
                 }
             }
             else
             {
-                log.error(o.getClass().getName() + " object set as runtime.log.logsystem is not a valid log implementation.");
+                String msg = o.getClass().getName() + " object set as runtime.log.logsystem is not a valid log implementation.";
+                log.error(msg);
+                throw new VelocityException(msg);
             }
         }
 
@@ -162,8 +168,9 @@
                     }
                     else
                     {
-                        log.error("The specified logger class " + claz +
-                                  " does not implement the "+LogChute.class.getName()+" interface.");
+                        String msg = "The specified logger class " + claz +
+                                     " does not implement the "+LogChute.class.getName()+" interface.";
+                        log.error(msg);
                         // be extra informative if it appears to be a classloader issue
                         // this should match all our provided LogChutes
                         if (isProbablyProvidedLogChute(claz))
@@ -171,6 +178,7 @@
                             // if it's likely to be ours, tip them off about classloader stuff
                             log.error("This appears to be a ClassLoader issue.  Check for multiple Velocity jars in your classpath.");
                         }
+                        throw new VelocityException(msg);
                     }
                 }
                 catch(NoClassDefFoundError ncdfe)
@@ -191,9 +199,11 @@
                 }
                 catch(Exception e)
                 {
+                    String msg = "Failed to initialize an instance of " + claz +
+                                 " with the current runtime configuration.";
                     // log unexpected init exception at higher priority
-                    log.error("Failed to initialize an instance of " + claz +
-                              " with the current runtime configuration.", e);
+                    log.error(msg, e);
+                    throw new VelocityException(msg);
                 }
             }
         }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/Parser.java Tue Aug 19 15:00:32 2008
@@ -3,7 +3,7 @@
 
 import java.io.*;
 import java.util.*;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.node.*;
 import org.apache.velocity.runtime.directive.Directive;
@@ -125,7 +125,9 @@
         }
         catch (Exception e)
         {
-            rsvc.getLog().error("Parser Error: " + templateName, e);
+            String msg = "Parser Error: " + templateName;
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
         currentTemplateName = "";

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java Tue Aug 19 15:00:32 2008
@@ -25,6 +25,7 @@
 import org.apache.velocity.context.InternalContextAdapter;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.parser.Parser;
 import org.apache.velocity.util.introspection.Info;
 import org.apache.velocity.util.introspection.IntrospectionCacheData;
@@ -158,7 +159,9 @@
         }
         catch(Exception e)
         {
-            log.error("ASTIdentifier.execute() : identifier = "+identifier, e);
+            String msg = "ASTIdentifier.execute() : identifier = "+identifier;
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
         /*
@@ -238,11 +241,11 @@
         }
         catch(Exception e)
         {
-            log.error("ASTIdentifier() : exception invoking method "
+            String msg = "ASTIdentifier() : exception invoking method "
                         + "for identifier '" + identifier + "' in "
-                        + o.getClass() + " : " + e);
+                        + o.getClass();
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
-
-        return null;
     }
 }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Tue Aug 19 15:00:32 2008
@@ -27,6 +27,7 @@
 import org.apache.velocity.context.InternalContextAdapter;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.parser.Parser;
 import org.apache.velocity.util.introspection.Info;
 import org.apache.velocity.util.introspection.IntrospectionCacheData;
@@ -225,9 +226,9 @@
             /*
              *  can come from the doIntropection() also, from Introspector
              */
-
-            log.error("ASTMethod.execute() : exception from introspection", e);
-            return null;
+            String msg = "ASTMethod.execute() : exception from introspection";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
         try
@@ -273,9 +274,10 @@
         }
         catch( Exception e )
         {
-            log.error("ASTMethod.execute() : exception invoking method '"
-                      + methodName + "' in " + o.getClass(), e);
-            return null;
+            String msg = "ASTMethod.execute() : exception invoking method '"
+                         + methodName + "' in " + o.getClass();
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java Tue Aug 19 15:00:32 2008
@@ -28,6 +28,7 @@
 import org.apache.velocity.context.InternalContextAdapter;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.parser.Parser;
 import org.apache.velocity.runtime.parser.Token;
@@ -548,10 +549,11 @@
             /*
              *  maybe a security exception?
              */
-            log.error("ASTReference setValue() : exception : " + e
-                                  + " template = " + context.getCurrentTemplateName()
-                                  + " [" + this.getLine() + "," + this.getColumn() + "]");
-            return false;
+            String msg = "ASTReference setValue() : exception : " + e
+                          + " template = " + context.getCurrentTemplateName()
+                          + " [" + this.getLine() + "," + this.getColumn() + "]";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
          }
 
         return true;

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java Tue Aug 19 15:00:32 2008
@@ -27,6 +27,7 @@
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.parser.ParseException;
 import org.apache.velocity.runtime.parser.Parser;
@@ -274,23 +275,6 @@
             }
 
             /**
-             * For interpolated Strings we do not pass exceptions through --
-             * just log the problem and move on.
-             */
-            catch (ParseErrorException e)
-            {
-                log.error("Error in interpolating string literal", e);
-            }
-            catch (MethodInvocationException e)
-            {
-                log.error("Error in interpolating string literal", e);
-            }
-            catch (ResourceNotFoundException e)
-            {
-                log.error("Error in interpolating string literal", e);
-            }
-
-            /**
              * pass through application level runtime exceptions
              */
             catch (RuntimeException e)
@@ -300,7 +284,9 @@
 
             catch (IOException e)
             {
-                log.error("Error in interpolating string literal", e);
+                String msg = "Error in interpolating string literal";
+                log.error(msg, e);
+                throw new VelocityException(msg, e);
             }
 
         }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java Tue Aug 19 15:00:32 2008
@@ -19,6 +19,7 @@
  * under the License.    
  */
 
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeLogger;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.runtime.log.RuntimeLoggerLog;
@@ -113,7 +114,9 @@
         }
         catch(Exception e)
         {
-            log.error("While looking for boolean property getter for '" + property + "':", e);
+            String msg = "Exception while looking for boolean property getter for '" + property;
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/GetExecutor.java Tue Aug 19 15:00:32 2008
@@ -20,7 +20,7 @@
  */
 
 import java.lang.reflect.InvocationTargetException;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeLogger;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.runtime.log.RuntimeLoggerLog;
@@ -102,7 +102,9 @@
         }
         catch(Exception e)
         {
-            log.error("While looking for get('" + params[0] + "') method:", e);
+            String msg = "Exception while looking for get('" + params[0] + "') method";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java Tue Aug 19 15:00:32 2008
@@ -20,7 +20,7 @@
  */
 
 import java.util.Map;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.log.Log;
 
 /**
@@ -66,7 +66,9 @@
                 }
                 catch(Exception e)
                 {
-                    log.error("While looking for get('" + property + "') method:", e);
+                    String msg = "Exception while looking for get('" + property + "') method";
+                    log.error(msg, e);
+                    throw new VelocityException(msg, e);
                 }
                 break;
             }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java Tue Aug 19 15:00:32 2008
@@ -20,7 +20,7 @@
  */
 
 import java.util.Map;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.log.Log;
 
 /**
@@ -66,7 +66,9 @@
                 }
                 catch(Exception e)
                 {
-                    log.error("While looking for get('" + property + "') method:", e);
+                    String msg = "Exception while looking for put('" + property + "') method";
+                    log.error(msg, e);
+                    throw new VelocityException(msg, e);
                 }
                 break;
             }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java Tue Aug 19 15:00:32 2008
@@ -22,6 +22,7 @@
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeLogger;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.runtime.log.RuntimeLoggerLog;
@@ -126,7 +127,9 @@
         }
         catch(Exception e)
         {
-            log.error("While looking for property getter for '" + property + "':", e);
+            String msg = "Exception while looking for property getter for '" + property;
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PutExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PutExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PutExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/PutExecutor.java Tue Aug 19 15:00:32 2008
@@ -20,7 +20,7 @@
  */
 
 import java.lang.reflect.InvocationTargetException;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.util.introspection.Introspector;
 
@@ -97,7 +97,9 @@
         }
         catch(Exception e)
         {
-            log.error("While looking for put('" + params[0] + "') method:", e);
+            String msg = "Exception while looking for put('" + params[0] + "') method";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java Tue Aug 19 15:00:32 2008
@@ -23,6 +23,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.text.StrBuilder;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.util.introspection.Introspector;
 
@@ -114,7 +115,9 @@
         }
         catch(Exception e)
         {
-            log.error("While looking for property setter for '" + property + "':", e);
+            String msg = "Exception while looking for property setter for '" + property;
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ContentResource.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ContentResource.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ContentResource.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ContentResource.java Tue Aug 19 15:00:32 2008
@@ -22,8 +22,8 @@
 import java.io.StringWriter;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
-
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 
 /**
  * This class represent a general text resource that may have been
@@ -84,8 +84,9 @@
         }
         catch ( Exception e )
         {
-            rsvc.getLog().error("Cannot process content resource", e);
-            return false;
+            String msg = "Cannot process content resource";
+            rsvc.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
         finally
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java Tue Aug 19 15:00:32 2008
@@ -101,7 +101,7 @@
     {
         if (isInit)
         {
-            log.error("Re-initialization of ResourceLoader attempted!");
+            log.debug("Re-initialization of ResourceLoader attempted and ignored.");
             return;
         }
 	
@@ -135,12 +135,12 @@
             }
             else
             {
-                log.error("Unable to find '" +
+                String msg = "Unable to find '" +
                           configuration.getString(RESOURCE_LOADER_IDENTIFIER) +
                           ".resource.loader.class' specification in configuration." +
-                          " This is a critical value.  Please adjust configuration.");
-
-                continue; // for(...
+                          " This is a critical value.  Please adjust configuration.";
+                log.error(msg);
+                throw new Exception(msg);
             }
 
             resourceLoader.commonInit(rsvc, configuration);
@@ -171,17 +171,18 @@
             }
             catch (ClassNotFoundException cnfe)
             {
-                log.error("The specified class for ResourceCache (" + cacheClassName +
-                          ") does not exist or is not accessible to the current classloader.");
-                cacheObject = null;
+                String msg = "The specified class for ResourceCache (" + cacheClassName +
+                          ") does not exist or is not accessible to the current classloader.";
+                log.error(msg, cnfe);
+                throw cnfe;
             }
 
             if (!(cacheObject instanceof ResourceCache))
             {
-                log.error("The specified class for ResourceCache (" + cacheClassName +
-                          ") does not implement " + ResourceCache.class.getName() +
-                          " ResourceManager. Using default ResourceCache implementation.");
-                cacheObject = null;
+                String msg = "The specified resource cache class (" + cacheClassName +
+                          ") must implement " + ResourceCache.class.getName();
+                log.error(msg);
+                throw new RuntimeException(msg);
             }
         }
 
@@ -233,7 +234,7 @@
 
             if (loaderConfiguration == null)
             {
-                log.error("ResourceManager : No configuration information for resource loader named '" +
+                log.debug("ResourceManager : No configuration information for resource loader named '" +
                           loaderName + "'. Skipping.");
 
                 continue;
@@ -335,6 +336,7 @@
             }
             catch (RuntimeException re)
             {
+                log.error("ResourceManager.getResource() exception", re);
         	    throw re;
             }
             catch (Exception e)
@@ -370,6 +372,7 @@
             }
             catch (RuntimeException re)
             {
+                log.error("ResourceManager.getResource() load exception", re);
     		    throw re;
             }
             catch (Exception e)

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -31,6 +31,7 @@
 import javax.sql.DataSource;
 import org.apache.commons.collections.ExtendedProperties;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.resource.Resource;
 import org.apache.velocity.util.ExceptionUtils;
 import org.apache.velocity.util.StringUtils;
@@ -173,7 +174,9 @@
         }
         else
         {
-            log.error("DataSourceResourceLoader not properly initialized. No DataSource was identified.");
+            String msg = "DataSourceResourceLoader not properly initialized. No DataSource was identified.";
+            log.error(msg);
+            throw new RuntimeException(msg);
         }
     }
 
@@ -286,7 +289,9 @@
         String name = resource.getName();
         if (name == null || name.length() == 0)
         {
-            log.error("DataSourceResourceLoader: Template name was empty or null");
+            String msg = "DataSourceResourceLoader: Template name was empty or null";
+            log.error(msg);
+            throw new NullPointerException(msg);
         }
         else
         {
@@ -305,8 +310,10 @@
                 }
                 else
                 {
-                    log.error("DataSourceResourceLoader: could not find resource "
-                              + name + " while " + operation);
+                    String msg = "DataSourceResourceLoader: could not find resource "
+                              + name + " while " + operation;
+                    log.error(msg);
+                    throw new ResourceNotFoundException(msg);
                 }
             }
             catch (SQLException sqle)
@@ -374,7 +381,9 @@
             }
             catch (Exception e)
             {
-                log.error("DataSourceResourceLoader: problem when closing connection", e);
+                String msg = "DataSourceResourceLoader: problem when closing connection";
+                log.error(msg, e);
+                throw new VelocityException(msg, e);
             }
         }
     }
@@ -396,7 +405,9 @@
             }
             catch (Exception e)
             {
-                log.error("DataSourceResourceLoader: problem when closing result set", e);
+                String msg = "DataSourceResourceLoader: problem when closing result set";
+                log.error(msg, e);
+                throw new VelocityException(msg, e);
             }
         }
     }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -33,6 +33,7 @@
 
 import org.apache.commons.collections.ExtendedProperties;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.io.UnicodeInputStream;
 import org.apache.velocity.runtime.resource.Resource;
 import org.apache.velocity.util.StringUtils;
@@ -152,7 +153,9 @@
             }
             catch (IOException ioe)
             {
-                log.error("While loading Template " + template + ": ", ioe);
+                String msg = "Exception while loading Template " + template;
+                log.error(msg, ioe);
+                throw new VelocityException(msg, ioe);
             }
 
             if (inputStream != null)

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java Tue Aug 19 15:00:32 2008
@@ -31,6 +31,7 @@
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.exception.VelocityException;
 
 /**
  * A small wrapper around a Jar
@@ -84,8 +85,10 @@
         }
         catch (IOException ioe)
         {
-            log.error("JarHolder: error establishing connection to JAR at \""
-                      + urlpath + "\"", ioe);
+            String msg = "JarHolder: error establishing connection to JAR at \""
+                         + urlpath + "\"";
+            log.error(msg, ioe);
+            throw new VelocityException(msg, ioe);
         }
     }
 
@@ -100,7 +103,9 @@
         }
         catch ( Exception e )
         {
-            log.error("JarHolder: error closing the JAR file", e);
+            String msg = "JarHolder: error closing the JAR file";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
         theJar = null;
         conn = null;

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -132,12 +132,15 @@
         // Check path information
         if ( path == null )
         {
-            log.error("JarResourceLoader : can not load JAR - JAR path is null");
+            String msg = "JarResourceLoader : can not load JAR - JAR path is null";
+            log.error(msg);
+            throw new RuntimeException(msg);
         }
         if ( !path.startsWith("jar:") )
         {
-            log.error("JarResourceLoader : JAR path must start with jar: -> " +
-                "see java.net.JarURLConnection for information");
+            String msg = "JarResourceLoader : JAR path must start with jar: -> see java.net.JarURLConnection for information";
+            log.error(msg);
+            throw new RuntimeException(msg);
         }
         if ( !path.endsWith("!/") )
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -25,9 +25,8 @@
 import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.runtime.resource.Resource;
 import org.apache.velocity.runtime.resource.ResourceCacheImpl;
-
 import org.apache.velocity.exception.ResourceNotFoundException;
-
+import org.apache.velocity.exception.VelocityException;
 import org.apache.commons.collections.ExtendedProperties;
 
 /**
@@ -88,7 +87,9 @@
         catch (Exception e)
         {
             isCachingOn = false;
-            log.error("Exception using default of '" + isCachingOn + '\'', e);
+            String msg = "Exception parsing cache setting: "+configuration.getString("cache");
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
         try
         {
@@ -97,8 +98,9 @@
         catch (Exception e)
         {
             modificationCheckInterval = 0;
-            log.error("Exception using default of '" +
-                      modificationCheckInterval + '\'', e);
+            String msg = "Exception parsing modificationCheckInterval setting: "+configuration.getString("modificationCheckInterval");
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
 
         /*
@@ -111,7 +113,9 @@
         }
         catch (Exception e)
         {
-            log.error("Exception using default of '" + className + '\'', e);
+            String msg = "Exception retrieving resource cache class name";
+            log.error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java Tue Aug 19 15:00:32 2008
@@ -19,6 +19,7 @@
  * under the License.    
  */
 
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.util.ClassUtils;
 import org.apache.velocity.util.StringUtils;
@@ -55,13 +56,11 @@
         // The ugly three strike again: ClassNotFoundException,IllegalAccessException,InstantiationException
         catch(Exception e)
         {
-            rs.getLog().error("Problem instantiating the template loader.\n" +
-                          "Look at your properties file and make sure the\n" +
-                          "name of the template loader is correct. Here is the\n" +
-                          "error:", e);
-
-            throw new Exception("Problem initializing template loader: " + loaderClassName +
-            "\nError is: " + StringUtils.stackTrace(e));
+            String msg = "Problem instantiating the template loader: "+loaderClassName+".\n" +
+                         "Look at your properties file and make sure the\n" +
+                         "name of the template loader is correct.";
+            rs.getLog().error(msg, e);
+            throw new VelocityException(msg, e);
         }
     }
 }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -257,8 +257,9 @@
             // warn them if they are trying to change the class of the repository
             if (!this.repository.getClass().getName().equals(repoClass))
             {
-                log.error("Cannot change class of string repository '"+repoName+
-                          "' from "+this.repository.getClass().getName()+" to "+repoClass);
+                log.debug("Cannot change class of string repository '"+repoName+
+                          "' from "+this.repository.getClass().getName()+" to "+repoClass+
+                          ". The change will be ignored.");
             }
 
             // allow them to change the default encoding of the repo

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java Tue Aug 19 15:00:32 2008
@@ -171,9 +171,9 @@
         catch (IOException ioe)
         {
             // the file is not reachable at its previous address
-            log.error("URLResourceLoader: '" + name +
-                      "' is no longer reachable at '" + root + "'", ioe);
-            return 0;
+            String msg = "URLResourceLoader: '"+name+"' is no longer reachable at '"+root+"'";
+            log.error(msg, ioe);
+            throw new ResourceNotFoundException(msg, ioe);
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Introspector.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Introspector.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Introspector.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Introspector.java Tue Aug 19 15:00:32 2008
@@ -123,7 +123,7 @@
             msg.append(") for class ")
                     .append(c);
 
-            log.error(msg.toString());
+            log.debug(msg.toString());
         }
 
         return null;

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java Tue Aug 19 15:00:32 2008
@@ -157,7 +157,7 @@
                 }
                 else
                 {
-                    log.error("iterator() method of reference in #foreach loop at "
+                    log.debug("iterator() method of reference in #foreach loop at "
                               + i + " does not return a true Iterator.");
                 }
             }
@@ -168,7 +168,7 @@
         }
 
         /*  we have no clue what this is  */
-        log.error("Could not determine type of iterator in #foreach loop at " + i);
+        log.debug("Could not determine type of iterator in #foreach loop at " + i);
 
         return null;
     }

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java Tue Aug 19 15:00:32 2008
@@ -82,8 +82,9 @@
 
         // actual instance of logger
         logger = new TestLogChute();
+        logger.off();
         Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
-        Velocity.setProperty("runtime.log.logsystem.test.level", "error");
+        Velocity.setProperty("runtime.log.logsystem.test.level", "debug");
         Velocity.init();
     }
 
@@ -98,7 +99,10 @@
         VelocityContext context = new VelocityContext();
         Template template = Velocity.getTemplate("macros.vm");
 
+        // try to get only messages during merge
+        logger.on();
         template.merge(context, new StringWriter());
+        logger.off();
 
         String resultLog = logger.getLog();
         if ( !isMatch(resultLog, COMPARE_DIR, "velocity.log", "cmp"))

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/misc/TestLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/TestLogChute.java?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/misc/TestLogChute.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/misc/TestLogChute.java Tue Aug 19 15:00:32 2008
@@ -36,6 +36,7 @@
     private StringBuffer log = new StringBuffer();
 
     private int logLevel;
+    private boolean on;
     
     public void init(RuntimeServices rs) throws Exception
     {
@@ -43,9 +44,19 @@
         logLevel = getLevelNumber(level, LogChute.DEBUG_ID);
     }
 
+    public void on()
+    {
+        on = true;
+    }
+
+    public void off()
+    {
+        on = false;
+    }
+
     public void log(int level, String message)
     {
-        if (level >= logLevel)
+        if (on && level >= logLevel)
         {
             String levelName;
             levelName = getLevelName(level);
@@ -140,7 +151,7 @@
     
     public void log(int level, String message, Throwable t)
     {
-        if (level >= logLevel)
+        if (on && level >= logLevel)
         {
             String levelName;
             levelName = getLevelName(level);

Modified: velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp (original)
+++ velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp Tue Aug 19 15:00:32 2008
@@ -1,8 +1,8 @@
- [error] VM #test1: error : too few arguments to macro. Wanted 1 got 0
- [error] VM #test2: error : too few arguments to macro. Wanted 1 got 0
- [error] VM #test3: error : too few arguments to macro. Wanted 1 got 0
- [error] VM #test4: error : too few arguments to macro. Wanted 1 got 0
- [error] VM #test1: error : too many arguments to macro. Wanted 1 got 2
- [error] VM #test2: error : too many arguments to macro. Wanted 1 got 2
- [error] VM #test3: error : too many arguments to macro. Wanted 1 got 2
- [error] VM #test4: error : too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test1: too few arguments to macro. Wanted 1 got 0
+ [debug] VM #test2: too few arguments to macro. Wanted 1 got 0
+ [debug] VM #test3: too few arguments to macro. Wanted 1 got 0
+ [debug] VM #test4: too few arguments to macro. Wanted 1 got 0
+ [debug] VM #test1: too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test2: too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test3: too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test4: too many arguments to macro. Wanted 1 got 2

Modified: velocity/engine/trunk/test/macroforwarddefine/macros.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/macroforwarddefine/macros.vm?rev=687177&r1=687176&r2=687177&view=diff
==============================================================================
--- velocity/engine/trunk/test/macroforwarddefine/macros.vm (original)
+++ velocity/engine/trunk/test/macroforwarddefine/macros.vm Tue Aug 19 15:00:32 2008
@@ -9,7 +9,7 @@
 #end
 
 #macro(test2 $p)
- $p
+ $!p
 #end
 
 #macro(test3 $p)