[ 
https://issues.apache.org/jira/browse/OFBIZ-1843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606959#action_12606959
 ] 

Amit Shinde commented on OFBIZ-1843:
------------------------------------

Attached patch for this enhancement.

Description -

I have created properties to control levels of display of exceptions on 
frontend due to ftl errors. The properties are in debug.properties -

# Catch Freemarker Exceptions 
#freemarker.exception.display.level property values can be IGNORE_ALL or 
IGNORE_OPTIMAL or IGNORE_NONE
freemarker.exception.display.level=IGNORE_NONE

#set 'freemarker.exception.suppress' property to Y only if we want to suppress 
exceptions containing specific words specified in 
#'freemarker.exception.contains' property
freemarker.exception.suppress=N

#'freemarker.exception.contains' property will suppress errors containing 
specific words in exceptions like com.yourcompanyname ONLY when 
#'freemarker.exception.suppress' is set to Y
freemarker.exception.contains=com.yourcompanyname

#'freemarker.exception.message' property is the replacement text we use to 
display the error stack trace ONLY when 'freemarker.exception.suppress' is #set 
to Y
freemarker.exception.message=Error occurred on rendering


'freemarker.exception.display.level' Property - This property controls the 
level of exception we want to show on frontend. Its values are IGNORE_ALL or 
IGNORE_OPTIMAL or IGNORE_NONE. The exceptions will only be written to logs in 
all cases.

    * IGNORE_NONE - When this value is set, whole stack trace will be 
displayed. This what we see right now by default. Snapshot - 
http://screencast.com/t/mn4urtKk7Y
    * IGNORE_OPTIMAL - When this value is set, only one line of error is 
displayed and the remaining page (section after error) is rendered as well. 
This is the best level for us and I have set it in debug.properties as well. 
Snapshot - http://screencast.com/t/lksaILn5Y
    * IGNORE_ALL - This value takes the highest precedence and ignores ALL 
exceptions and nothing will be displayed on frontend at all. Snapshot - 
http://screencast.com/t/uunS2fxRD


Custom Exception Suppression - This is used ONLY when we want to suppress a 
certain exception that has specific string in it and replace that stack with a 
custom error message. This functionality will work only when 
'freemarker.exception.display.level' is IGNORE_OPTIMAL or IGNORE_NONE. This 
requires all the remaining 3 properties -

    * freemarker.exception.suppress=Y (Enable suppression)
    * freemarker.exception.contains=com.yourcompanyname (if the exception 
contains "com.yourcompanyname" string, replace the stack with custom message. 
We can add more strings separated by pipes ('|').)
    * freemarker.exception.message=Error occurred on rendering (if suppression 
is enabled and stack contains all of the above strings, then replace stack with 
this message)

    * Snapshots -
          o When suppression is disabled and 
'freemarker.exception.display.level' is IGNORE_NONE - 
http://screencast.com/t/QAvok41vWWL
          o When suppression is enabled and 
'freemarker.exception.display.level' is IGNORE_NONE or IGNORE_OPTIMAL - 
http://screencast.com/t/eyqM50IzCW



> Suppress stack traces on front end due to errors in ftl files
> -------------------------------------------------------------
>
>                 Key: OFBIZ-1843
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1843
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL COMPONENTS
>            Reporter: Amit Shinde
>         Attachments: OFBIZ-1843.patch
>
>
> We need to find a way to gracefully handle stack traces that appear within 
> freemarker on front end due to errors in ftl files. Instead of displaying 
> stack traces to the end user, we should have a simple, configurable way of 
> controlling levels of error messages that should be displayed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to