I am trying to implement a simple custom error page after any unhandled exception is thrown by Grails code. I matched 500 with my controller:
"500" ( controller: "error", action: "serverError" )
and handled the exception in the controller:
def serverError = { try { // first check, if some exception was reported if (!request.exception) { return } // send mail with stack trace if requested if (shouldSendErrorReports) { log.debug "Mail was sent out successfully..." } } catch (Throwable e) { log.error "Error while reporting an error: " + e } // redirect to error message redirect ( action: "errorMessage" ) } // lines omitted for clarity
The errorMessage action is just a view, which by default makes a GSP page with static content - information and a click-to-redirect window. The page has (hopefully) the correct prolog:
<%@ page contentType="text/html;charset=UTF-8" %> <%@ page isErrorPage="true" %>
Now, testing it locally through NetBeans (Jetty), everything works fine and the errorMessage page is displayed; when deployed in a TEST environment (Tomcat6), the Tomcat stack trace is displayed.
How to prevent Tomcat stack trace from showing? I have two thoughts - firstly, I'm not dumping (processing?) Correctly, an exception, so it bubbles up on Tomcat - secondly, Tomcat has a specific configuration value, so it still displays the stack trace.
Please, if you have any thoughts on this, let me know. Spend about 5 hours figuring this out ...: - /
Thanks!
mx0r
source share