Example usage for org.springframework.web.servlet DispatcherServlet EXCEPTION_ATTRIBUTE

List of usage examples for org.springframework.web.servlet DispatcherServlet EXCEPTION_ATTRIBUTE

Introduction

In this page you can find the example usage for org.springframework.web.servlet DispatcherServlet EXCEPTION_ATTRIBUTE.

Prototype

String EXCEPTION_ATTRIBUTE

To view the source code for org.springframework.web.servlet DispatcherServlet EXCEPTION_ATTRIBUTE.

Click Source Link

Document

Name of request attribute that exposes an Exception resolved with an HandlerExceptionResolver but where no view was rendered (e.g.

Usage

From source file:org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.java

private void filterAndRecordMetrics(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain, Object handler) throws IOException, ServletException {
    TimingContext timingContext = TimingContext.get(request);
    if (timingContext == null) {
        timingContext = startAndAttachTimingContext(request, handler);
    }//from w w w  .j ava2 s  .  c om
    try {
        filterChain.doFilter(request, response);
        if (!request.isAsyncStarted()) {
            // Only record when async processing has finished or never been started.
            // If async was started by something further down the chain we wait
            // until the second filter invocation (but we'll be using the
            // TimingContext that was attached to the first)
            Throwable exception = (Throwable) request.getAttribute(DispatcherServlet.EXCEPTION_ATTRIBUTE);
            record(timingContext, response, request, handler, exception);
        }
    } catch (NestedServletException ex) {
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        record(timingContext, response, request, handler, ex.getCause());
        throw ex;
    }
}