1 52 53 package freemarker.template; 54 55 import java.io.Writer ; 56 import java.io.PrintWriter ; 57 import freemarker.core.Environment; 58 59 64 65 public interface TemplateExceptionHandler { 66 67 73 void handleTemplateException(TemplateException te, Environment env, Writer out) 74 throws TemplateException; 75 76 77 82 TemplateExceptionHandler IGNORE_HANDLER = new TemplateExceptionHandler() { 83 public void handleTemplateException(TemplateException te, Environment env, Writer out) { 84 } 85 }; 86 87 91 TemplateExceptionHandler RETHROW_HANDLER =new TemplateExceptionHandler() { 92 public void handleTemplateException(TemplateException te, Environment env, Writer out) 93 throws TemplateException 94 { 95 throw te; 96 } 97 }; 98 99 103 TemplateExceptionHandler DEBUG_HANDLER =new TemplateExceptionHandler() { 104 public void handleTemplateException(TemplateException te, Environment env, Writer out) 105 throws TemplateException 106 { 107 PrintWriter pw = (out instanceof PrintWriter ) 108 ? (PrintWriter ) out 109 : new PrintWriter (out); 110 te.printStackTrace(pw); 111 pw.flush(); 112 throw te; 113 } 114 }; 115 116 121 TemplateExceptionHandler HTML_DEBUG_HANDLER =new TemplateExceptionHandler() { 122 public void handleTemplateException(TemplateException te, Environment env, Writer out) 123 throws TemplateException 124 { 125 PrintWriter pw = (out instanceof PrintWriter ) 126 ? (PrintWriter ) out 127 : new PrintWriter (out); 128 pw.println("<!-- FREEMARKER ERROR MESSAGE STARTS HERE -->" 129 + "<script language=javascript>//\"></script>" 130 + "<script language=javascript>//\'></script>" 131 + "<script language=javascript>//\"></script>" 132 + "<script language=javascript>//\'></script>" 133 + "</title></xmp></script></noscript></style></object>" 134 + "</head></pre></table>" 135 + "</form></table></table></table></a></u></i></b>" 136 + "<div align=left " 137 + "style='background-color:#FFFF00; color:#FF0000; " 138 + "display:block; border-top:double; padding:2pt; " 139 + "font-size:medium; font-family:Arial,sans-serif; " 140 + "font-style: normal; font-variant: normal; " 141 + "font-weight: normal; text-decoration: none; " 142 + "text-transform: none'>" 143 + "<b style='font-size:medium'>FreeMarker template error!</b>" 144 + "<pre><xmp>"); 145 te.printStackTrace(pw); 146 pw.println("</xmp></pre></div></html>"); 147 pw.flush(); 148 throw te; 149 } 150 }; 151 } 152 | Popular Tags |