freemarker.core.Environment.isInAttemptBlock()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中freemarker.core.Environment.isInAttemptBlock()方法的一些代码示例,展示了Environment.isInAttemptBlock()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.isInAttemptBlock()方法的具体详情如下:
包路径:freemarker.core.Environment
类名称:Environment
方法名:isInAttemptBlock

Environment.isInAttemptBlock介绍

[英]Tells if we are inside an #attempt block (but before #recover). This can be useful for TemplateExceptionHandler-s, as then they may don't want to print the error to the output, as #attempt will roll it back anyway.
[中]告诉我们是否在#尝试块内(但在#恢复之前)。这对于TemplateExceptionHandler-s很有用,因为这样他们可能不想将错误打印到输出中,因为#尝试无论如何都会回滚错误。

代码示例

代码示例来源:origin: org.freemarker/freemarker

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. PrintWriter pw = (out instanceof PrintWriter) ? (PrintWriter) out : new PrintWriter(out);
  5. pw.print("FreeMarker template error (DEBUG mode; use RETHROW in production!):\n");
  6. te.printStackTrace(pw, false, true, true);
  7. pw.flush(); // To commit the HTTP response
  8. }
  9. throw te;
  10. }
  11. };

代码示例来源:origin: org.freemarker/freemarker

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. boolean externalPw = out instanceof PrintWriter;
  5. PrintWriter pw = externalPw ? (PrintWriter) out : new PrintWriter(out);

代码示例来源:origin: org.freemarker/freemarker

  1. && !isInAttemptBlock() /* because then the AttemptExceptionReporter will report this */) {
  2. LOG.error("Error executing FreeMarker template", templateException);
  3. } catch (TemplateException e) {
  4. if (isInAttemptBlock()) {
  5. this.getAttemptExceptionReporter().report(templateException, this);

代码示例来源:origin: org.freemarker/freemarker-gae

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. PrintWriter pw = (out instanceof PrintWriter) ? (PrintWriter) out : new PrintWriter(out);
  5. pw.print("FreeMarker template error (DEBUG mode; use RETHROW in production!):\n");
  6. te.printStackTrace(pw, false, true, true);
  7. pw.flush(); // To commit the HTTP response
  8. }
  9. throw te;
  10. }
  11. };

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. PrintWriter pw = (out instanceof PrintWriter) ? (PrintWriter) out : new PrintWriter(out);
  5. pw.print("FreeMarker template error (DEBUG mode; use RETHROW in production!):\n");
  6. te.printStackTrace(pw, false, true, true);
  7. pw.flush(); // To commit the HTTP response
  8. }
  9. throw te;
  10. }
  11. };

代码示例来源:origin: org.freemarker/freemarker-gae

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. boolean externalPw = out instanceof PrintWriter;
  5. PrintWriter pw = externalPw ? (PrintWriter) out : new PrintWriter(out);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. public void handleTemplateException(TemplateException te, Environment env, Writer out)
  2. throws TemplateException {
  3. if (!env.isInAttemptBlock()) {
  4. boolean externalPw = out instanceof PrintWriter;
  5. PrintWriter pw = externalPw ? (PrintWriter) out : new PrintWriter(out);

代码示例来源:origin: org.freemarker/freemarker-gae

  1. && !isInAttemptBlock() /* because then the AttemptExceptionReporter will report this */) {
  2. LOG.error("Error executing FreeMarker template", templateException);
  3. } catch (TemplateException e) {
  4. if (isInAttemptBlock()) {
  5. this.getAttemptExceptionReporter().report(templateException, this);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. && !isInAttemptBlock() /* because then the AttemptExceptionReporter will report this */) {
  2. LOG.error("Error executing FreeMarker template", templateException);
  3. } catch (TemplateException e) {
  4. if (isInAttemptBlock()) {
  5. this.getAttemptExceptionReporter().report(templateException, this);

相关文章

Environment类方法