Freemarker exceptions

thumbnail
Joaquin Cabal, modified 6 Years ago. Regular Member Posts: 106 Join Date: 9/7/09 Recent Posts

Hi, anyone knows if is possible catch any freemarker exception? 

For example A simple NullPointerException. Only to show an error message and no the exception stack trace in the view.

 

Thanks!

Vishal Munjani, modified 6 Years ago. Junior Member Posts: 33 Join Date: 2/21/17 Recent Posts

Hello,

 

You can use below code to handle exception in freemarker.

<#attempt>
  <em>attempt block</em>
&lt;#recover&gt;
  <em>recover block</em>
&lt;/#attempt&gt;

For more you can refer https://freemarker.apache.org/docs/ref_directive_attempt.html