You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Daniel Dekany (JIRA)" <ji...@apache.org> on 2017/09/26 22:06:00 UTC

[jira] [Comment Edited] (FREEMARKER-48) When custom fremarker method throws exception, it is impossible to find line/row where called

    [ https://issues.apache.org/jira/browse/FREEMARKER-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16181657#comment-16181657 ] 

Daniel Dekany edited comment on FREEMARKER-48 at 9/26/17 10:05 PM:
-------------------------------------------------------------------

So it can't really be fixed as usual, due to backward compatibility constraints, but 2.3.27 addresses it:
* Added {{catch_unchecked_exceptions}} configuration setting to address this. It defaults to {{false}} for backward compatibility.
* Also, regardless of the {{catch_unchecked_exceptions}} setting, if {{incompatible_improvements}} is set to at least 2.3.27, we will wrap the following exceptions (but not their subclasses) into {{TemplateException}}: NullPointerException, ClassCastException, IndexOutOfBoundsException, and InvocationTargetException. This should cover most cases without introducing much backward compatibility risks.


was (Author: ddekany):
So it can't really be fixed as usual, due to backward compatibility constraints, but 2.3.27 addresses it:
* Added {{catch_template_exceptions}} configuration setting to address this. It defaults to {{false}} for backward compatibility.
* Also, regardless of the {{catch_template_exceptions}} setting, if {{incompatible_improvements}} is set to at least 2.3.27, we will wrap the following exceptions (but not their subclasses) into {{TemplateException}}: NullPointerException, ClassCastException, IndexOutOfBoundsException, and InvocationTargetException. This should cover most cases without introducing much backward compatibility risks.

> When custom fremarker method throws exception, it is impossible to find line/row where called
> ---------------------------------------------------------------------------------------------
>
>                 Key: FREEMARKER-48
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-48
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.25-incubating, 2.3.26-incubating
>         Environment: Any
>            Reporter: Vojtech Knyttl
>             Fix For: 2.3.27-incubating
>
>
> Consider this stacktrace:
> https://gist.github.com/knyttl/dba8f94b9736eb2751074c34dce7b467
> On line `DispatcherServlet.renderView(DispatcherServlet.java:308)` I have started freemarker to render a template. During that process it uses custom method (`HrefMethod.exec(HrefMethod.java:28)`), but this method threw an exception. However Freemarker does not report a line/row of the template where this method was called making it very hard for debug.
> I would be happy if `freemarker.core.MethodCall._eval(MethodCall.java:65)` had some try-catch blcok, that in case of an exception would add lines/rows/details of the element that caused the exception.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)