Merge pull request #13174 from izeye:render-error-view

* pr/13174:
  Polish DefaultErrorWebExceptionHandler.renderErrorView()
pull/13211/head
Stephane Nicoll 7 years ago
commit ba2e9cccf7

@ -121,18 +121,15 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
HttpStatus errorStatus = getHttpStatus(error); HttpStatus errorStatus = getHttpStatus(error);
ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus) ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus)
.contentType(MediaType.TEXT_HTML); .contentType(MediaType.TEXT_HTML);
Flux<ServerResponse> result = Flux return Flux
.just("error/" + errorStatus.toString(), .just("error/" + errorStatus.toString(),
"error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error") "error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error")
.flatMap((viewName) -> renderErrorView(viewName, responseBody, error)); .flatMap((viewName) -> renderErrorView(viewName, responseBody, error))
if (this.errorProperties.getWhitelabel().isEnabled()) { .switchIfEmpty(
result = result.switchIfEmpty(renderDefaultErrorView(responseBody, error)); this.errorProperties.getWhitelabel().isEnabled()
} ? renderDefaultErrorView(responseBody, error)
else { : Mono.error(getError(request)))
Throwable ex = getError(request); .next().doOnNext((response) -> logError(request, errorStatus));
result = result.switchIfEmpty(Mono.error(ex));
}
return result.next().doOnNext((response) -> logError(request, errorStatus));
} }
/** /**

Loading…
Cancel
Save