public abstract class AbstractErrorWebExceptionHandler extends Object implements ErrorWebExceptionHandler, org.springframework.beans.factory.InitializingBean
ErrorWebExceptionHandler implementations.ErrorAttributes| Constructor and Description |
|---|
AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes,
ResourceProperties resourceProperties,
org.springframework.context.ApplicationContext applicationContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected Throwable |
getError(org.springframework.web.reactive.function.server.ServerRequest request)
Extract the original error from the current request.
|
protected Map<String,Object> |
getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request,
boolean includeStackTrace)
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(ErrorAttributes errorAttributes)
Create a
RouterFunction that can route and handle errors as JSON responses
or HTML views. |
reactor.core.publisher.Mono<Void> |
handle(org.springframework.web.server.ServerWebExchange exchange,
Throwable throwable) |
protected boolean |
isTraceEnabled(org.springframework.web.reactive.function.server.ServerRequest request)
Check whether the trace attribute has been set on the given request.
|
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderDefaultErrorView(org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
Map<String,Object> error)
Render a default HTML "Whitelabel Error Page".
|
protected reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> |
renderErrorView(String viewName,
org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody,
Map<String,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(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)
Configure HTTP message readers to deserialize the request body with.
|
void |
setMessageWriters(List<org.springframework.http.codec.HttpMessageWriter<?>> messageWriters)
Configure HTTP message writers to serialize the response body with.
|
void |
setViewResolvers(List<org.springframework.web.reactive.result.view.ViewResolver> viewResolvers)
Configure the
ViewResolver to use for rendering views. |
public AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties, org.springframework.context.ApplicationContext applicationContext)
public void setMessageWriters(List<org.springframework.http.codec.HttpMessageWriter<?>> messageWriters)
messageWriters - the HttpMessageWriters to usepublic void setMessageReaders(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)
messageReaders - the HttpMessageReaders to usepublic void setViewResolvers(List<org.springframework.web.reactive.result.view.ViewResolver> viewResolvers)
ViewResolver to use for rendering views.viewResolvers - the list of ViewResolvers to useprotected Map<String,Object> getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request, boolean includeStackTrace)
request - the source requestincludeStackTrace - whether to include the error stacktrace informationprotected 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 reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> renderErrorView(String viewName, org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder responseBody, Map<String,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,
Map<String,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 Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionprotected abstract org.springframework.web.reactive.function.server.RouterFunction<org.springframework.web.reactive.function.server.ServerResponse> getRoutingFunction(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 errorsCopyright © 2018 Pivotal Software, Inc.. All rights reserved.