Package freemarker.template
Class TemplateException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- freemarker.template.TemplateException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Configurable.UnknownSettingException,InvalidReferenceException,StopException,TemplateModelException
public class TemplateException extends Exception
The FreeMarker classes usually use this exception and its descendants to signal FreeMarker specific exceptions.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TemplateException(Environment env)Constructs a TemplateException with no specified detail message or underlying cause.TemplateException(Exception cause, Environment env)Constructs a TemplateException with the given underlying Exception, but no detail message.TemplateException(String description, Environment env)Constructs a TemplateException with the given detail message, but no underlying cause exception.TemplateException(String description, Exception cause, Environment env)Constructs a TemplateException with both a description of the error that occurred and the underlying Exception that caused this exception to be raised.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExceptiongetCauseException()Returns the underlying exception that caused this exception to be generated.EnvironmentgetEnvironment()StringgetFTLInstructionStack()Returns the quote of the problematic FTL instruction and the FTL stack strace.List<freemarker.core.parser.TemplateLocation>getFTLStack()voidprintStackTrace(PrintStream ps)voidprintStackTrace(PrintWriter pw)-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
TemplateException
public TemplateException(Environment env)
Constructs a TemplateException with no specified detail message or underlying cause.
-
TemplateException
public TemplateException(String description, Environment env)
Constructs a TemplateException with the given detail message, but no underlying cause exception.- Parameters:
description- the description of the error that occurred
-
TemplateException
public TemplateException(Exception cause, Environment env)
Constructs a TemplateException with the given underlying Exception, but no detail message.- Parameters:
cause- the underlyingExceptionthat caused this exception to be raised
-
TemplateException
public TemplateException(String description, Exception cause, Environment env)
Constructs a TemplateException with both a description of the error that occurred and the underlying Exception that caused this exception to be raised.- Parameters:
description- the description of the error that occurredcause- the underlyingExceptionthat caused this exception to be raised
-
-
Method Detail
-
getCauseException
public Exception getCauseException()
Returns the underlying exception that caused this exception to be generated.
Note:
avoided calling itgetCauseto avoid name clash with JDK 1.4 method. This would be problematic because the JDK 1.4 method returns aThrowablerather than anException.- Returns:
- the underlying
Exception, if any, that caused this exception to be raised
-
getFTLInstructionStack
public String getFTLInstructionStack()
Returns the quote of the problematic FTL instruction and the FTL stack strace. As of FreeMarker 2.4, we provide access to the FTL instruction stack so you might prefer to use getFTLStack() and format the items in list yourself.- See Also:
getFTLStack()
-
getFTLStack
public List<freemarker.core.parser.TemplateLocation> getFTLStack()
- Returns:
- the FTL call stack (starting with current element)
-
getEnvironment
public Environment getEnvironment()
- Returns:
- the execution environment in which the exception occurred
-
printStackTrace
public void printStackTrace(PrintStream ps)
- Overrides:
printStackTracein classThrowable
-
printStackTrace
public void printStackTrace(PrintWriter pw)
- Overrides:
printStackTracein classThrowable
-
-