template.setTemplateExceptionHandler(getTemplateExceptionHandler());
public void merge(Map<String, Object> context, StringWriter writer) throws TemplateMergeException { try { template.process(context, writer); template.setTemplateExceptionHandler(new TemplateExceptionHandler() { @Override public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException { te.printStackTrace(); } }); } catch (TemplateException templateException) { LOGGER.error("Syntax error in report template: {}\n{}", templateException.getMessage(), templateException.getFTLInstructionStack()); throw new TemplateMergeException("Failed to process FreeMarker template", templateException); } catch (IOException e) { throw new TemplateMergeException("Could not read FreeMarker template", e); } catch (NumberFormatException e) { throw new TemplateMergeException("Number format exception during template merge", e); } } }
public void merge(Map<String, Object> context, StringWriter writer) throws TemplateMergeException { try { template.process(context, writer); template.setTemplateExceptionHandler(new TemplateExceptionHandler() { @Override public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException { te.printStackTrace(); } }); } catch (TemplateException templateException) { LOGGER.error("Syntax error in report template: {}\n{}", templateException.getMessage(), templateException.getFTLInstructionStack()); throw new TemplateMergeException("Failed to process FreeMarker template", templateException); } catch (IOException e) { throw new TemplateMergeException("Could not read FreeMarker template", e); } catch (NumberFormatException e) { throw new TemplateMergeException("Number format exception during template merge", e); } } }
Object exceptionHandler = ctx.getAttribute(FREEMARKER_EXCEPTION_HANDLER); if (exceptionHandler instanceof TemplateExceptionHandler) { template.setTemplateExceptionHandler((TemplateExceptionHandler) exceptionHandler);
template.setTemplateExceptionHandler(getTemplateExceptionHandler());
template.setTemplateExceptionHandler(getTemplateExceptionHandler());