Search in sources :

Example 1 with HandlerExceptionHandler

use of cn.taketoday.web.handler.HandlerExceptionHandler in project today-framework by TAKETODAY.

the class WebApplicationLoader method configureExceptionHandler.

/**
 * configure HandlerExceptionHandler
 *
 * @param handlers handlers in application-context {@link #obtainApplicationContext()}
 */
protected void configureExceptionHandler(List<HandlerExceptionHandler> handlers, WebMvcConfiguration mvcConfiguration) {
    DispatcherHandler dispatcherHandler = obtainDispatcher();
    HandlerExceptionHandler exceptionHandler = dispatcherHandler.getExceptionHandler();
    if (exceptionHandler != null) {
        handlers.add(exceptionHandler);
    }
    // user config
    mvcConfiguration.configureExceptionHandlers(handlers);
    // at least one exception-handler
    if (handlers.size() == 1) {
        exceptionHandler = handlers.get(0);
    } else {
        // @since 3.0.3 exception handlers order
        sort(handlers);
        exceptionHandler = new CompositeHandlerExceptionHandler(handlers);
    }
    // set
    dispatcherHandler.setExceptionHandler(exceptionHandler);
}
Also used : DispatcherHandler(cn.taketoday.web.handler.DispatcherHandler) CompositeHandlerExceptionHandler(cn.taketoday.web.handler.CompositeHandlerExceptionHandler) HandlerExceptionHandler(cn.taketoday.web.handler.HandlerExceptionHandler) CompositeHandlerExceptionHandler(cn.taketoday.web.handler.CompositeHandlerExceptionHandler)

Aggregations

CompositeHandlerExceptionHandler (cn.taketoday.web.handler.CompositeHandlerExceptionHandler)1 DispatcherHandler (cn.taketoday.web.handler.DispatcherHandler)1 HandlerExceptionHandler (cn.taketoday.web.handler.HandlerExceptionHandler)1