Search in sources :

Example 1 with ExceptionHandlingWebHandler

use of org.springframework.web.server.handler.ExceptionHandlingWebHandler in project spring-framework by spring-projects.

the class WebHttpHandlerBuilder method build.

/**
	 * Build the {@link HttpHandler}.
	 */
public HttpHandler build() {
    WebHandler decorated;
    decorated = new FilteringWebHandler(this.webHandler, this.filters);
    decorated = new ExceptionHandlingWebHandler(decorated, this.exceptionHandlers);
    HttpWebHandlerAdapter adapted = new HttpWebHandlerAdapter(decorated);
    if (this.sessionManager != null) {
        adapted.setSessionManager(this.sessionManager);
    }
    return adapted;
}
Also used : ExceptionHandlingWebHandler(org.springframework.web.server.handler.ExceptionHandlingWebHandler) FilteringWebHandler(org.springframework.web.server.handler.FilteringWebHandler) ExceptionHandlingWebHandler(org.springframework.web.server.handler.ExceptionHandlingWebHandler) WebHandler(org.springframework.web.server.WebHandler) FilteringWebHandler(org.springframework.web.server.handler.FilteringWebHandler)

Example 2 with ExceptionHandlingWebHandler

use of org.springframework.web.server.handler.ExceptionHandlingWebHandler in project spring-framework by spring-projects.

the class DispatcherHandlerErrorTests method webExceptionHandler.

@Test
public void webExceptionHandler() throws Exception {
    ServerWebExchange exchange = MockServerHttpRequest.get("/unknown-argument-type").toExchange();
    List<WebExceptionHandler> handlers = Collections.singletonList(new ServerError500ExceptionHandler());
    WebHandler webHandler = new ExceptionHandlingWebHandler(this.dispatcherHandler, handlers);
    webHandler.handle(exchange).block(Duration.ofSeconds(5));
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, exchange.getResponse().getStatusCode());
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) ExceptionHandlingWebHandler(org.springframework.web.server.handler.ExceptionHandlingWebHandler) WebExceptionHandler(org.springframework.web.server.WebExceptionHandler) WebHandler(org.springframework.web.server.WebHandler) ExceptionHandlingWebHandler(org.springframework.web.server.handler.ExceptionHandlingWebHandler) Test(org.junit.Test)

Aggregations

WebHandler (org.springframework.web.server.WebHandler)2 ExceptionHandlingWebHandler (org.springframework.web.server.handler.ExceptionHandlingWebHandler)2 Test (org.junit.Test)1 ServerWebExchange (org.springframework.web.server.ServerWebExchange)1 WebExceptionHandler (org.springframework.web.server.WebExceptionHandler)1 FilteringWebHandler (org.springframework.web.server.handler.FilteringWebHandler)1