public abstract class AbstractErrorWebExceptionHandler
extends java.lang.Object
implements org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler, org.springframework.beans.factory.InitializingBean
ErrorWebExceptionHandler implementations.ErrorAttributes| Constructor and Description |
|---|
AbstractErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
ResourceProperties resourceProperties,
org.springframework.context.ApplicationContext applicationContext)
Deprecated.
since 2.4.0 for removal in 2.6.0 in favor of
#AbstractErrorWebExceptionHandler(ErrorAttributes, Resources, ApplicationContext) |
AbstractErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
WebProperties.Resources resources,
org.springframework.context.ApplicationContext applicationContext)
Create a new
AbstractErrorWebExceptionHandler. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected java.lang.Throwable |
getError(org.springframework.web.reactive.function.server.ServerRequest request)
Extract the original error from the current request.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request,
boolean includeStackTrace)
Deprecated.
since 2.3.0 for removal in 2.5.0 in favor of
getErrorAttributes(ServerRequest, ErrorAttributeOptions) |
protected java.util.Map<java.lang.String,java.lang.Object> |
getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.boot.web.error.ErrorAttributeOptions options)
Extract the error attributes from the current request, to be used to populate error
views or JSON payloads.
|
protected abstract org.springframework.web.reactive.function.server.RouterFunction<org.springframework.web.reactive.function.server.ServerResponse> |
getRoutingFunction(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes)
Create a
RouterFunction that can route and handle errors as JSON responses
or HTML views. |
reactor.core.publisher.Mono<java.lang.Void> |
handle(org.springframework.web.server.ServerWebExchange exchange,
java.lang.Throwable throwable) |
protected boolean |
isBindingErrorsEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
Check whether the errors attribute has been set on the given request.
|
protected boolean |
isMessageEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
Check whether the message attribute has been set on the given request.
|
protected boolean |
isTraceEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
Check whether the trace attribute has been set on the given request.
|
protected void |
logError(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.web.reactive.function.server.ServerResponse response,
java.lang.Throwable throwable)
Logs the
throwable error for the given request and response
exchange. |
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderDefaultErrorView(org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
java.util.Map<java.lang.String,java.lang.Object> error)
Render a default HTML "Whitelabel Error Page".
|
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderErrorView(java.lang.String viewName,
org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
java.util.Map<java.lang.String,java.lang.Object> error)
Render the given error data as a view, using a template view if available or a
static HTML file if available otherwise.
|
void |
setMessageReaders(java.util.List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)
Configure HTTP message readers to deserialize the request body with.
|
void |
setMessageWriters(java.util.List<org.springframework.http.codec.HttpMessageWriter<?>> messageWriters)
Configure HTTP message writers to serialize the response body with.
|
void |
setViewResolvers(java.util.List<org.springframework.web.reactive.result.view.ViewResolver> viewResolvers)
Configure the
ViewResolver to use for rendering views. |
@Deprecated
public AbstractErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
ResourceProperties resourceProperties,
org.springframework.context.ApplicationContext applicationContext)
#AbstractErrorWebExceptionHandler(ErrorAttributes, Resources, ApplicationContext)AbstractErrorWebExceptionHandler.errorAttributes - the error attributesresourceProperties - the resource propertiesapplicationContext - the application contextpublic AbstractErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
WebProperties.Resources resources,
org.springframework.context.ApplicationContext applicationContext)
AbstractErrorWebExceptionHandler.errorAttributes - the error attributesresources - the resources configuration propertiesapplicationContext - the application contextpublic void setMessageWriters(java.util.List<org.springframework.http.codec.HttpMessageWriter<?>> messageWriters)
messageWriters - the HttpMessageWriters to usepublic void setMessageReaders(java.util.List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)
messageReaders - the HttpMessageReaders to usepublic void setViewResolvers(java.util.List<org.springframework.web.reactive.result.view.ViewResolver> viewResolvers)
ViewResolver to use for rendering views.viewResolvers - the list of ViewResolvers to use@Deprecated
protected java.util.Map<java.lang.String,java.lang.Object> getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request,
boolean includeStackTrace)
getErrorAttributes(ServerRequest, ErrorAttributeOptions)request - the source requestincludeStackTrace - whether to include the error stacktrace informationprotected java.util.Map<java.lang.String,java.lang.Object> getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.boot.web.error.ErrorAttributeOptions options)
request - the source requestoptions - options to control error attributesprotected java.lang.Throwable getError(org.springframework.web.reactive.function.server.ServerRequest request)
request - the source requestprotected boolean isTraceEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
request - the source requesttrue if the error trace has been requested, false otherwiseprotected boolean isMessageEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
request - the source requesttrue if the message attribute has been requested, false
otherwiseprotected boolean isBindingErrorsEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
request - the source requesttrue if the errors attribute has been requested, false
otherwiseprotected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> renderErrorView(java.lang.String viewName,
org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
java.util.Map<java.lang.String,java.lang.Object> error)
Publisher if none of the above are available.viewName - the view nameresponseBody - the error response being builterror - the error data as a mapServerResponseprotected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> renderDefaultErrorView(org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
java.util.Map<java.lang.String,java.lang.Object> error)
Useful when no other error view is available in the application.
responseBody - the error response being builterror - the error data as a mapServerResponsepublic void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionprotected abstract org.springframework.web.reactive.function.server.RouterFunction<org.springframework.web.reactive.function.server.ServerResponse> getRoutingFunction(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes)
RouterFunction that can route and handle errors as JSON responses
or HTML views.
If the returned RouterFunction doesn't route to a HandlerFunction,
the original exception is propagated in the pipeline and can be processed by other
WebExceptionHandlers.
errorAttributes - the ErrorAttributes instance to use to extract error
informationRouterFunction that routes and handles errorspublic reactor.core.publisher.Mono<java.lang.Void> handle(org.springframework.web.server.ServerWebExchange exchange,
java.lang.Throwable throwable)
handle in interface org.springframework.web.server.WebExceptionHandlerprotected void logError(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.web.reactive.function.server.ServerResponse response,
java.lang.Throwable throwable)
throwable error for the given request and response
exchange. The default implementation logs all errors at debug level. Additionally,
any internal server error (500) is logged at error level.request - the request that was being handledresponse - the response that was being sentthrowable - the error to be logged