You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by by...@apache.org on 2009/01/03 15:15:57 UTC

svn commit: r730988 - in /velocity/engine/branches/1.6.x/src: changes/changes.xml java/org/apache/velocity/runtime/parser/node/ASTReference.java

Author: byron
Date: Sat Jan  3 06:15:56 2009
New Revision: 730988

URL: http://svn.apache.org/viewvc?rev=730988&view=rev
Log:
VELOCITY-656 Improve error reporting when toString() throws an exceptionin #if() testing. moved from trunk

Modified:
    velocity/engine/branches/1.6.x/src/changes/changes.xml
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java

Modified: velocity/engine/branches/1.6.x/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/changes/changes.xml?rev=730988&r1=730987&r2=730988&view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/changes/changes.xml (original)
+++ velocity/engine/branches/1.6.x/src/changes/changes.xml Sat Jan  3 06:15:56 2009
@@ -28,6 +28,11 @@
 
     <release version="1.6.2-dev" date="In Subversion">
 
+      <action type="add" dev="byron" issue="VELOCITY-656">
+	 Better error reporting when toString() throw an exception
+	 when testing an #if conditional. For example #if($foo)
+      </action>
+      
       <action type="fix" dev="byron" issue="VELOCITY-658" due-to="Jarkko Viinamäki">
           Fix $velocityHasNext so that it works in nested foreach blocks.
       </action>

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=730988&r1=730987&r2=730988&view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java (original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java Sat Jan  3 06:15:56 2009
@@ -469,13 +469,19 @@
                 return true;
             else
                 return false;
-        }
-        else if (value.toString() == null)
+        }        
+        else
         {
-            return false;
+            try
+            {
+                return value.toString() != null;
+            }
+            catch(Exception e)
+            {
+                throw new VelocityException("Reference evaluation threw an exception at " 
+                    + Log.formatFileString(this), e);
+            }
         }
-        else
-            return true;
     }
 
     /**