@@ -112,8 +112,8 @@ public static Configuration makeConfiguration(BeansWrapper wrapper) {
112
112
boolean verboseTemplate = ModelWidget .widgetBoundaryCommentsEnabled (null )
113
113
|| UtilProperties .getPropertyAsBoolean ("widget" , "widget.freemarker.template.verbose" , false );
114
114
newConfig .setTemplateExceptionHandler (verboseTemplate
115
- ? OFBizTemplateExceptionHandler . OFBIZ_DEBUG_HANDLER
116
- : OFBizTemplateExceptionHandler . OFBIZ_DEFAULT_HANDLER );
115
+ ? FreeMarkerWorker :: handleTemplateExceptionVerbosily
116
+ : FreeMarkerWorker :: handleTemplateException );
117
117
try {
118
118
newConfig .setSetting ("datetime_format" , "yyyy-MM-dd HH:mm:ss.SSS" );
119
119
newConfig .setSetting ("number_format" , "0.##########" );
@@ -498,34 +498,45 @@ protected URL getURL(String name) {
498
498
}
499
499
500
500
/**
501
- * OFBiz specific {@link TemplateExceptionHandler} interface.
501
+ * Handles template exceptions quietly.
502
+ * <p>
503
+ * This is done by suppressing the exception and replacing it by a generic char for quiet alert.
504
+ * Note that exception is still logged.
505
+ * <p>
506
+ * This implements the {@link TemplateExceptionHandler} functional interface.
507
+ *
508
+ * @param te the exception that occurred
509
+ * @param env the runtime environment of the template
510
+ * @param out this is where the output of the template is written
502
511
*/
503
- interface OFBizTemplateExceptionHandler {
504
-
505
- /**
506
- * {@link TemplateExceptionHandler} that suppresses the exception and keep the rendering going on.
507
- * It sanitizes any messages present in the stack trace prior to printing to the output writer.
508
- */
509
- TemplateExceptionHandler OFBIZ_DEBUG_HANDLER = (te , env , out ) -> {
510
- try {
511
- out .write (te .getMessage ());
512
- Debug .logError (te , module );
513
- } catch (IOException e ) {
514
- Debug .logError (e , module );
515
- }
516
- };
512
+ private static void handleTemplateException (TemplateException te , Environment env , Writer out ) {
513
+ try {
514
+ out .write (UtilProperties .getPropertyValue ("widget" , "widget.freemarker.template.exception.message" , "∎" ));
515
+ Debug .logError (te , module );
516
+ } catch (IOException e ) {
517
+ Debug .logError (e , module );
518
+ }
519
+ }
517
520
518
- /**
519
- * {@link TemplateExceptionHandler} that suppresses the exception and replace by a generic char for quiet alert.
520
- * As mentioned in the doc, the stack trace is still logged {@link TemplateExceptionHandler#IGNORE_HANDLER}
521
- */
522
- TemplateExceptionHandler OFBIZ_DEFAULT_HANDLER = (te , env , out ) -> {
523
- try {
524
- out .write (UtilProperties .getPropertyValue ("widget" , "widget.freemarker.template.exception.message" ,"∎" ));
525
- Debug .logError (te , module );
526
- } catch (IOException e ) {
527
- Debug .logError (e , module );
528
- }
529
- };
521
+ /**
522
+ * Handles template exceptions verbosely.
523
+ * <p>
524
+ * This is done by suppressing the exception and keeping the rendering going on. Messages
525
+ * present in the stack trace are sanitized before printing them to the output writer.
526
+ * Note that exception is still logged.
527
+ * <p>
528
+ * This implements the {@link TemplateExceptionHandler} functional interface.
529
+ *
530
+ * @param te the exception that occurred
531
+ * @param env the runtime environment of the template
532
+ * @param out this is where the output of the template is written
533
+ */
534
+ private static void handleTemplateExceptionVerbosily (TemplateException te , Environment env , Writer out ) {
535
+ try {
536
+ out .write (te .getMessage ());
537
+ Debug .logError (te , module );
538
+ } catch (IOException e ) {
539
+ Debug .logError (e , module );
540
+ }
530
541
}
531
542
}
0 commit comments