aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2019-09-08 10:42:47 +0000
committerClaude Brisson <cbrisson@apache.org>2019-09-08 10:42:47 +0000
commit5782c4cfa7beab546f778d51d5af2c3503e76aec (patch)
tree5bd4ca076135fa41f3d8be47c15cba1f323d3312 /velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
parentacf40deb4da66c5852b16244f3d818e46ed2b7c2 (diff)
downloadapache-velocity-engine-5782c4cfa7beab546f778d51d5af2c3503e76aec.tar.gz
[VELOCITY-916] Add a second effect for the debugging flag runtime.log.track_location: display VTL stacktrace on errors
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1866609 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java b/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
index 8dccb151..dc6de702 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
@@ -19,6 +19,8 @@ package org.apache.velocity.exception;
* under the License.
*/
+import org.apache.velocity.runtime.parser.LogContext;
+
/**
* Base class for Velocity runtime exceptions thrown to the
* application layer.
@@ -34,6 +36,16 @@ public class VelocityException extends RuntimeException
private static final long serialVersionUID = 1251243065134956045L;
/**
+ * LogContext VTL location tracking context
+ */
+ private LogContext logContext = null;
+
+ /**
+ * VTL vtlStackTrace, populated at construction when runtime.log.track_location is true
+ */
+ private String vtlStackTrace[] = null;
+
+ /**
* @param exceptionMessage The message to register.
*/
public VelocityException(final String exceptionMessage)
@@ -52,6 +64,18 @@ public class VelocityException extends RuntimeException
}
/**
+ * @param exceptionMessage The message to register.
+ * @param wrapped A throwable object that caused the Exception.
+ * @param vtlStackTrace VTL stacktrace
+ * @since 2.2
+ */
+ public VelocityException(final String exceptionMessage, final Throwable wrapped, final String[] vtlStackTrace)
+ {
+ super(exceptionMessage, wrapped);
+ this.vtlStackTrace = vtlStackTrace;
+ }
+
+ /**
* @param wrapped A throwable object that caused the Exception.
* @since 1.5
*/
@@ -61,6 +85,17 @@ public class VelocityException extends RuntimeException
}
/**
+ * @param wrapped A throwable object that caused the Exception.
+ * @param vtlStackTrace VTL stacktrace
+ * @since 2.2
+ */
+ public VelocityException(final Throwable wrapped, final String[] vtlStackTrace)
+ {
+ super(wrapped);
+ this.vtlStackTrace = vtlStackTrace;
+ }
+
+ /**
* returns the wrapped Throwable that caused this
* MethodInvocationException to be thrown
*
@@ -73,4 +108,8 @@ public class VelocityException extends RuntimeException
return getCause();
}
+ public String[] getVtlStackTrace()
+ {
+ return vtlStackTrace;
+ }
}