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;
}
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());
}
Aggregations