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:
  • Constructor Details

    • 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 underlying Exception that 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 occurred
      cause - the underlying Exception that caused this exception to be raised
  • Method Details

    • getCauseException

      public Exception getCauseException()

      Returns the underlying exception that caused this exception to be generated.

      Note:
      avoided calling it getCause to avoid name clash with JDK 1.4 method. This would be problematic because the JDK 1.4 method returns a Throwable rather than an Exception.

      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

      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:
      printStackTrace in class Throwable
    • printStackTrace

      public void printStackTrace(PrintWriter pw)
      Overrides:
      printStackTrace in class Throwable