I have this code in java :
try{
//some code here.. .
} catch (Exception e) {
message = "Error occurred : " + e.getCause();
throw e;
}
And in freemarker :
<table width="1238" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center" class="Fontmost">
<p><@ww.property value = "message"/> <!-- message from java -->
<br />
<br />
</p>
</td>
</tr>
</table>
The last developer of the application that i’m maintaining uses e.getCause() instead of e.getMessage() . For now, we need only the exception message because e.getCause() prints the whole stack trace in the page. Is there any way to show only the exception message by just modifying the freemarker code?, because all the classes and modules in our java code uses e.getCause(), we have 40 modules to change if we modify e.getCause() to e.getMessage().
I appreciate any help coming from you guys.
Thanks in advance.
I suggest you add the exception itself to the model (e.g. under the name “exception”) and use it in the template:
exception.messageorexception.cause.message, depending on the exception you want.