jvanzyl 00/10/21 18:27:38
Modified: src/java/org/apache/velocity Template.java
src/java/org/apache/velocity/runtime Runtime.java
src/java/org/apache/velocity/runtime/directive Foreach.java
src/java/org/apache/velocity/test Test.java
Log:
- adding proper logging for parsing exceptions cause by syntax
errors in templates.
Revision Changes Path
1.10 +11 -14 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Template.java 2000/10/21 02:00:17 1.9
+++ Template.java 2000/10/22 01:27:32 1.10
@@ -59,6 +59,7 @@
import java.io.Writer;
import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.SimpleNode;
/**
@@ -81,7 +82,7 @@
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Template.java,v 1.9 2000/10/21 02:00:17 jvanzyl Exp $
+ * @version $Id: Template.java,v 1.10 2000/10/22 01:27:32 jvanzyl Exp $
*/
public class Template
{
@@ -116,20 +117,16 @@
* Velocity Runtime. This AST structure can be
* reused until the template changes on disk.
*/
- public Template(InputStream inputStream) throws Exception
+ public Template(InputStream inputStream)
{
- parse(inputStream);
- }
-
- /**
- * Parse a template which is passed in the form
- * of an InputStream. The Velocity Runtime
- * produces an AST node structure from the
- * InputStream.
- */
- protected void parse(InputStream inputStream) throws Exception
- {
- document = Runtime.parse(inputStream);
+ try
+ {
+ document = Runtime.parse(inputStream);
+ }
+ catch (ParseException pe)
+ {
+ Runtime.error(pe);
+ }
}
/**
1.23 +3 -2
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
Index: Runtime.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Runtime.java 2000/10/21 02:00:17 1.22
+++ Runtime.java 2000/10/22 01:27:34 1.23
@@ -73,6 +73,7 @@
import org.apache.velocity.Template;
import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.velocity.runtime.loader.TemplateFactory;
@@ -138,7 +139,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Bowden</a>
- * @version $Id: Runtime.java,v 1.22 2000/10/21 02:00:17 jvanzyl Exp $
+ * @version $Id: Runtime.java,v 1.23 2000/10/22 01:27:34 jvanzyl Exp $
*/
public class Runtime
{
@@ -351,7 +352,7 @@
* AST node structure.
*/
public synchronized static SimpleNode parse(InputStream inputStream)
- throws Exception
+ throws ParseException
{
return parser.parse(inputStream);
}
1.13 +5 -0
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
Index: Foreach.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Foreach.java 2000/10/21 03:21:03 1.12
+++ Foreach.java 2000/10/22 01:27:36 1.13
@@ -119,6 +119,11 @@
// the SimpleNode.init() and logged. But we also need
// to set a flag so that the rendering of this node
// is ignored as the output would be useless.
+
+ // Slight problem with this approach. The list object
+ // may have been #set previously, this usually wouldn't
+ // be the case, but this check should be moved into
+ // the rendering phase.
if (listObject == null)
{
node.setInvalid();
1.3 +1 -2 jakarta-velocity/src/java/org/apache/velocity/test/Test.java
Index: Test.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/Test.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Test.java 2000/10/20 02:19:54 1.2
+++ Test.java 2000/10/22 01:27:36 1.3
@@ -72,7 +72,7 @@
* test all the directives support by Velocity.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Test.java,v 1.2 2000/10/20 02:19:54 jvanzyl Exp $
+ * @version $Id: Test.java,v 1.3 2000/10/22 01:27:36 jvanzyl Exp $
*/
public class Test
{
@@ -116,7 +116,6 @@
}
catch( Exception e )
{
- e.printStackTrace();
Runtime.error(e);
}
}