springboot webflux 异常处理(WebExceptionHandler)
*************************
相关类及接口
WebExceptionHandler
public interface WebExceptionHandler {
Mono<Void> handle(ServerWebExchange var1, Throwable var2);
}
ErrorWebExceptionHandler
@FunctionalInterface
public interface ErrorWebExceptionHandler extends WebExceptionHandler {
}
AbstractErrorWebExceptionHandler
public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExceptionHandler, InitializingBean {
private static final Set<String> DISCONNECTED_CLIENT_EXCEPTIONS;
private static final Log logger;
private final ApplicationContext applicationContext;
private final ErrorAttributes errorAttributes;
private final ResourceProperties resourceProperties;
private final TemplateAvailabilityProviders templateAvailabilityProviders;
private List<HttpMessageReader<?>> messageReaders = Collections.emptyList();
private List<HttpMessageWriter<?>> messageWriters = Collections.emptyList();
private List<ViewResolver> viewResolvers = Collections.emptyList();
public AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, ApplicationContext applicationContext) {
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
Assert.notNull(resourceProperties, "ResourceProperties must not be null");
Assert.notNull(applicationContext, "ApplicationContext must not be null");
this.errorAttributes = errorAttributes;
this.resourceProperties = resourceProperties;
this.applicationContext = applicationContext;
this.templateAvailabilityProviders = new TemplateAvailabilityProviders(applicationContext);
}
public void setMessageWriters(List<HttpMessageWriter<?>> messageWriters) {
Assert.notNull(messageWriters, "'messageWriters' must not be null");
this.messageWriters = messageWriters;
}
public void setMessageReaders(List<HttpMessageReader<?>> messageReaders) {
Assert.notNull(messageReaders, "'messageReaders' must not be null");
this.messageReaders = messageReaders;
}
public void setViewResolvers(List<ViewResolver> viewResolvers) {
this.viewResolvers = viewResolvers;
}
/** @deprecated */
@Deprecated
protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
return this.getErrorAttributes(request, includeStackTrace ? ErrorAttributeOptions.of(new Include[]{Include.STACK_TRACE}) : ErrorAttributeOptions.defaults());
}
protected Map<String, Object> getErrorAttributes(ServerRequest request, ErrorAttributeOptions options) {
return this.errorAttributes.getErrorAttributes(request, options);
}
protected Throwable getError(ServerRequest request) {
return this.errorAttributes.getError(request);
}
protected boolean isTraceEnabled(ServerRequest request) {
return this.getBooleanParameter(request, "trace");
}
protected boolean isMessageEnabled(ServerRequest request) {
return this.getBooleanParameter(request, "message");
}
protected boolean isBindingErrorsEnabled(ServerRequest request) {
return this.getBooleanParameter(request, "errors");
}
private boolean getBooleanParameter(ServerRequest request, String parameterName) {
String parameter = (String)request.queryParam(parameterName