Package freemarker.template
Interface TemplateExceptionHandler
-
public interface TemplateExceptionHandlerUsed for thetemplate_exception_handlerconfiguration setting; seeConfigurable.setTemplateExceptionHandler(TemplateExceptionHandler)for more.
-
-
Field Summary
Fields Modifier and Type Field Description static TemplateExceptionHandlerDEBUG_HANDLERTemplateExceptionHandleruseful when you developing non-HTML templates.static TemplateExceptionHandlerHTML_DEBUG_HANDLERTemplateExceptionHandleruseful when you developing HTML templates.static TemplateExceptionHandlerIGNORE_HANDLERTemplateExceptionHandlerthat simply skips the failing instructions, letting the template continue executing.static TemplateExceptionHandlerRETHROW_HANDLERTemplateExceptionHandlerthat simply re-throws the exception; this should be used in most production systems.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidhandleTemplateException(TemplateException te, Environment env, Writer out)Method called after aTemplateExceptionwas raised inside a template.
-
-
-
Field Detail
-
IGNORE_HANDLER
static final TemplateExceptionHandler IGNORE_HANDLER
TemplateExceptionHandlerthat simply skips the failing instructions, letting the template continue executing. It does nothing to handle the event. Note that the exception is still logged, as with all otherTemplateExceptionHandler-s.
-
RETHROW_HANDLER
static final TemplateExceptionHandler RETHROW_HANDLER
TemplateExceptionHandlerthat simply re-throws the exception; this should be used in most production systems.
-
DEBUG_HANDLER
static final TemplateExceptionHandler DEBUG_HANDLER
TemplateExceptionHandleruseful when you developing non-HTML templates. This handler outputs the stack trace information to the client and then re-throws the exception.
-
HTML_DEBUG_HANDLER
static final TemplateExceptionHandler HTML_DEBUG_HANDLER
TemplateExceptionHandleruseful when you developing HTML templates. This handler outputs the stack trace information to the client, formatting it so that it will be usually well readable in the browser, and then re-throws the exception.
-
-
Method Detail
-
handleTemplateException
void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException
Method called after aTemplateExceptionwas raised inside a template. The error is logged before this is called, so there's no need to log it here. The exception should be re-thrown unless you want to suppress the exception.Note that you can check with
Environment.isInAttemptBlock()if you are inside a#attemptblock, which then will handle handle this exception and roll back the output generated inside it.Note that
StopException-s (raised by#stop) won't be captured.- Parameters:
te- The exception that occurred; don't forget to re-throw it unless you want to suppress itenv- The runtime environment of the templateout- This is where the output of the template is written- Throws:
TemplateException
-
-