public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler
WebExceptionHandler, rendering
ErrorAttributes.
More specific errors can be handled either using Spring WebFlux abstractions (e.g.
@ExceptionHandler with the annotation model) or by adding
RouterFunction to the chain.
This implementation will render error as HTML views if the client explicitly supports
that media type. It attempts to resolve error views using well known conventions. Will
search for templates and static assets under '/error' using the
status code and the status series.
For example, an HTTP 404 will search (in the specific order):
'/<templates>/error/404.<ext>''/<static>/error/404.html''/<templates>/error/4xx.<ext>''/<static>/error/4xx.html''/<templates>/error/error''/<static>/error/error.html'If none found, a default "Whitelabel Error" HTML view will be rendered.
If the client doesn't support HTML, the error information will be rendered as a JSON payload.
| Constructor and Description |
|---|
DefaultErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
ResourceProperties resourceProperties,
ErrorProperties errorProperties,
org.springframework.context.ApplicationContext applicationContext)
Deprecated.
since 2.4.0 for removal in 2.6.0 in favor of
#DefaultErrorWebExceptionHandler(ErrorAttributes, Resources, ErrorProperties, ApplicationContext) |
DefaultErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
WebProperties.Resources resources,
ErrorProperties errorProperties,
org.springframework.context.ApplicationContext applicationContext)
Create a new
DefaultErrorWebExceptionHandler instance. |
| Modifier and Type | Method and Description |
|---|---|
protected org.springframework.web.reactive.function.server.RequestPredicate |
acceptsTextHtml()
Predicate that checks whether the current request explicitly support
"text/html" media type. |
protected org.springframework.boot.web.error.ErrorAttributeOptions |
getErrorAttributeOptions(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType mediaType) |
protected int |
getHttpStatus(java.util.Map<java.lang.String,java.lang.Object> errorAttributes)
Get the HTTP error status information from the error map.
|
protected 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. |
protected boolean |
isIncludeBindingErrors(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
Determine if the errors attribute should be included.
|
protected boolean |
isIncludeMessage(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
Determine if the message attribute should be included.
|
protected boolean |
isIncludeStackTrace(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
Determine if the stacktrace attribute should be included.
|
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderErrorResponse(org.springframework.web.reactive.function.server.ServerRequest request)
Render the error information as a JSON payload.
|
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderErrorView(org.springframework.web.reactive.function.server.ServerRequest request)
Render the error information as an HTML view.
|
afterPropertiesSet, getError, getErrorAttributes, getErrorAttributes, handle, isBindingErrorsEnabled, isMessageEnabled, isTraceEnabled, logError, renderDefaultErrorView, renderErrorView, setMessageReaders, setMessageWriters, setViewResolvers@Deprecated
public DefaultErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
ResourceProperties resourceProperties,
ErrorProperties errorProperties,
org.springframework.context.ApplicationContext applicationContext)
#DefaultErrorWebExceptionHandler(ErrorAttributes, Resources, ErrorProperties, ApplicationContext)DefaultErrorWebExceptionHandler instance.errorAttributes - the error attributesresourceProperties - the resources configuration propertieserrorProperties - the error configuration propertiesapplicationContext - the current application contextpublic DefaultErrorWebExceptionHandler(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes,
WebProperties.Resources resources,
ErrorProperties errorProperties,
org.springframework.context.ApplicationContext applicationContext)
DefaultErrorWebExceptionHandler instance.errorAttributes - the error attributesresources - the resources configuration propertieserrorProperties - the error configuration propertiesapplicationContext - the current application contextprotected org.springframework.web.reactive.function.server.RouterFunction<org.springframework.web.reactive.function.server.ServerResponse> getRoutingFunction(org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributes)
AbstractErrorWebExceptionHandlerRouterFunction 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.
getRoutingFunction in class AbstractErrorWebExceptionHandlererrorAttributes - the ErrorAttributes instance to use to extract error
informationRouterFunction that routes and handles errorsprotected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> renderErrorView(org.springframework.web.reactive.function.server.ServerRequest request)
request - the current requestPublisher of the HTTP responseprotected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> renderErrorResponse(org.springframework.web.reactive.function.server.ServerRequest request)
request - the current requestPublisher of the HTTP responseprotected org.springframework.boot.web.error.ErrorAttributeOptions getErrorAttributeOptions(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType mediaType)
protected boolean isIncludeStackTrace(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
request - the source requestproduces - the media type produced (or MediaType.ALL)protected boolean isIncludeMessage(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
request - the source requestproduces - the media type produced (or MediaType.ALL)protected boolean isIncludeBindingErrors(org.springframework.web.reactive.function.server.ServerRequest request,
org.springframework.http.MediaType produces)
request - the source requestproduces - the media type produced (or MediaType.ALL)protected int getHttpStatus(java.util.Map<java.lang.String,java.lang.Object> errorAttributes)
errorAttributes - the current error informationprotected org.springframework.web.reactive.function.server.RequestPredicate acceptsTextHtml()
"text/html" media type.
The "match-all" media type is not considered here.