Class DefaultErrorAttributes
- java.lang.Object
- org.springframework.boot.autoconfigure.web.DefaultErrorAttributes
- All Implemented Interfaces:
ErrorAttributes,org.springframework.core.Ordered,org.springframework.web.servlet.HandlerExceptionResolver
@Order(-2147483648) public class DefaultErrorAttributes extends Object implements ErrorAttributes, org.springframework.web.servlet.HandlerExceptionResolver, org.springframework.core.Ordered
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
- message - The exception message
- errors - Any
ObjectErrors from aBindingResultexception - trace - The exception stack trace
- path - The URL path when the exception was raised
- Since:
- 1.1.0
- See Also:
ErrorAttributes
Constructor Summary
Constructors Constructor Description DefaultErrorAttributes()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowablegetError(org.springframework.web.context.request.RequestAttributes requestAttributes)Return the underlying cause of the error ornullif the error cannot be extracted.Map<String,Object>getErrorAttributes(org.springframework.web.context.request.RequestAttributes requestAttributes, boolean includeStackTrace)Returns aMapof the error attributes.intgetOrder()org.springframework.web.servlet.ModelAndViewresolveException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex)
Constructor Detail
DefaultErrorAttributes
public DefaultErrorAttributes()
Method Detail
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
resolveException
public org.springframework.web.servlet.ModelAndView resolveException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex)
- Specified by:
resolveExceptionin interfaceorg.springframework.web.servlet.HandlerExceptionResolver
getErrorAttributes
public Map<String,Object> getErrorAttributes(org.springframework.web.context.request.RequestAttributes requestAttributes, boolean includeStackTrace)
Description copied from interface:ErrorAttributesReturns aMapof the error attributes. The map can be used as the model of an error pageModelAndView, or returned as aResponseBody.- Specified by:
getErrorAttributesin interfaceErrorAttributes- Parameters:
requestAttributes- the source request attributesincludeStackTrace- if stack trace elements should be included- Returns:
- a map of error attributes
getError
public Throwable getError(org.springframework.web.context.request.RequestAttributes requestAttributes)
Description copied from interface:ErrorAttributesReturn the underlying cause of the error ornullif the error cannot be extracted.- Specified by:
getErrorin interfaceErrorAttributes- Parameters:
requestAttributes- the source request attributes- Returns:
- the
Exceptionthat caused the error ornull