Log exception in ErrorPageFilter

Fixes gh-1130
pull/1132/head
Dave Syer 11 years ago
parent 772df9bea7
commit 51496b4e4f

@ -136,18 +136,18 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
request.setAttribute(ERROR_EXCEPTION, ex); request.setAttribute(ERROR_EXCEPTION, ex);
request.setAttribute(ERROR_EXCEPTION_TYPE, type.getName()); request.setAttribute(ERROR_EXCEPTION_TYPE, type.getName());
wrapped.sendError(500, ex.getMessage()); wrapped.sendError(500, ex.getMessage());
forwardToErrorPage(errorPath, request, wrapped); forwardToErrorPage(errorPath, request, wrapped, ex);
} }
private void forwardToErrorPage(String path, HttpServletRequest request, private void forwardToErrorPage(String path, HttpServletRequest request,
ServletResponse response) throws ServletException, IOException { ServletResponse response, Throwable ex) throws ServletException, IOException {
if (!response.isCommitted()) { if (!response.isCommitted()) {
String message = "Cannot forward to error page for" + request.getRequestURI() String message = "Cannot forward to error page for" + request.getRequestURI()
+ " (response is committed), so this response may have " + " (response is committed), so this response may have "
+ "the wrong status code"; + "the wrong status code";
// User might see the error page without all the data here but the exception // User might see the error page without all the data here but throwing the
// isn't going to help anyone (and it's already been logged) // exception isn't going to help anyone (we'll log it to be on the safe side)
logger.error(message); logger.error(message, ex);
return; return;
} }
response.reset(); response.reset();

Loading…
Cancel
Save