Class DefaultErrorAttributes
- java.lang.Object
- org.springframework.boot.web.reactive.error.DefaultErrorAttributes
- All Implemented Interfaces:
ErrorAttributes
public class DefaultErrorAttributes extends Object implements ErrorAttributes
Default implementation ofErrorAttributes
. Provides the following attributes when possible:- timestamp - The time that the errors were extracted
- status - The status code
- error - The error reason
- exception - The class name of the root exception (if configured)
- message - The exception message
- errors - Any
ObjectError
s from aBindingResult
exception - trace - The exception stack trace
- path - The URL path when the exception was raised
- Since:
- 2.0.0
- See Also:
ErrorAttributes
Constructor Summary
Constructors Constructor Description DefaultErrorAttributes()
Create a newDefaultErrorAttributes
instance that does not include the "exception" attribute.DefaultErrorAttributes(boolean includeException)
Create a newDefaultErrorAttributes
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
getError(org.springframework.web.reactive.function.server.ServerRequest request)
Return the underlying cause of the error ornull
if the error cannot be extracted.Map<String,Object>
getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request, boolean includeStackTrace)
Return aMap
of the error attributes.void
storeErrorInformation(Throwable error, org.springframework.web.server.ServerWebExchange exchange)
Store the given error information in the currentServerWebExchange
.
Constructor Detail
DefaultErrorAttributes
public DefaultErrorAttributes()
Create a newDefaultErrorAttributes
instance that does not include the "exception" attribute.
DefaultErrorAttributes
public DefaultErrorAttributes(boolean includeException)
Create a newDefaultErrorAttributes
instance.- Parameters:
includeException
- whether to include the "exception" attribute
Method Detail
getErrorAttributes
public Map<String,Object> getErrorAttributes(org.springframework.web.reactive.function.server.ServerRequest request, boolean includeStackTrace)
Description copied from interface:ErrorAttributes
Return aMap
of the error attributes. The map can be used as the model of an error page, or returned as aServerResponse
body.- Specified by:
getErrorAttributes
in interfaceErrorAttributes
- Parameters:
request
- the source requestincludeStackTrace
- if stack trace elements should be included- Returns:
- a map of error attributes
getError
public Throwable getError(org.springframework.web.reactive.function.server.ServerRequest request)
Description copied from interface:ErrorAttributes
Return the underlying cause of the error ornull
if the error cannot be extracted.- Specified by:
getError
in interfaceErrorAttributes
- Parameters:
request
- the source ServerRequest- Returns:
- the
Exception
that caused the error ornull
storeErrorInformation
public void storeErrorInformation(Throwable error, org.springframework.web.server.ServerWebExchange exchange)
Description copied from interface:ErrorAttributes
Store the given error information in the currentServerWebExchange
.- Specified by:
storeErrorInformation
in interfaceErrorAttributes
- Parameters:
error
- theException
that caused the errorexchange
- the source exchange