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/10/13 19:42:11 UTC
svn commit: r704179 - in /velocity/engine/trunk/src: changes/changes.xml
java/org/apache/velocity/runtime/parser/node/ASTDirective.java
java/org/apache/velocity/util/introspection/Info.java
test/org/apache/velocity/test/issues/Velocity627TestCase.java
Author: nbubna
Date: Mon Oct 13 10:42:11 2008
New Revision: 704179
URL: http://svn.apache.org/viewvc?rev=704179&view=rev
Log:
VELOCITY-627 fix line number for exceptions with #foreach (thx to Byron Foster)
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java (with props)
Modified:
velocity/engine/trunk/src/changes/changes.xml
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java
Modified: velocity/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=704179&r1=704178&r2=704179&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Mon Oct 13 10:42:11 2008
@@ -27,6 +27,14 @@
<body>
<release version="1.6" date="In Subversion">
+ <action type="fix" dev="nbubna" issue="VELOCITY-627" due-to="Byron Foster">
+ Fix line number for exceptions with body of #foreach directive.
+ </action>
+
+ <action type="add" dev="nbubna" issue="VELOCITY-626" due-to="Byron Foster">
+ Log full macro stack when a RuntimeException occurs in a template.
+ </action>
+
<action type="add" dev="nbubna" issue="VELOCITY-622" due-to="Byron Foster">
Format template and line/column numbers consistently in error and log messages.
</action>
Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=704179&r1=704178&r2=704179&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java Mon Oct 13 10:42:11 2008
@@ -121,9 +121,9 @@
e);
}
- directive.init(rsvc, context,this);
directive.setLocation( getLine(), getColumn() );
+ directive.init(rsvc, context,this);
}
else
{
@@ -132,7 +132,8 @@
*/
directive = new RuntimeMacro(directiveName,
context.getCurrentTemplateName());
-
+ directive.setLocation( getLine(), getColumn() );
+
/**
* Initialize it
*/
@@ -152,8 +153,6 @@
die.getColumnNumber() + getColumn(),
die.getLineNumber() + getLine());
}
- directive.setLocation( getLine(), getColumn() );
-
isDirective = true;
}
Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java?rev=704179&r1=704178&r2=704179&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java Mon Oct 13 10:42:11 2008
@@ -19,6 +19,8 @@
* under the License.
*/
+import org.apache.velocity.runtime.log.Log;
+
/**
* Little class to carry in info such as template name, line and column
* for information error reporting from the uberspector implementations
@@ -84,7 +86,6 @@
*/
public String toString()
{
- return getTemplateName() + " [line " + getLine() + ", column " +
- getColumn() + ']';
+ return Log.formatFileString(getTemplateName(), getLine(), getColumn());
}
}
Added: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java?rev=704179&view=auto
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java (added)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java Mon Oct 13 10:42:11 2008
@@ -0,0 +1,56 @@
+package org.apache.velocity.test.issues;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.velocity.test.BaseEvalTestCase;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * This class tests VELOCITY-627. Make sure Foreach
+ * Error message reports correct line numbers.
+ */
+
+public class Velocity627TestCase extends BaseEvalTestCase
+{
+ public Velocity627TestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ engine.setProperty(RuntimeConstants.SKIP_INVALID_ITERATOR, false);
+ }
+
+ public void test627()
+ {
+ try
+ {
+ evaluate("##\n##\n#foreach($i in \"junk\")blaa#end");
+ }
+ catch(RuntimeException e)
+ {
+ // Make sure the error ouput contains "line 3" if not throw
+ if (e.getMessage().indexOf("[line 3, column") == -1)
+ throw e;
+ }
+ }
+}
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java
------------------------------------------------------------------------------
svn:keywords = Revision
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity627TestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain