public abstract class AbstractServiceErrorAttributes extends DefaultErrorAttributesX
| Constructor and Description |
|---|
AbstractServiceErrorAttributes()
Create a new
AbstractServiceErrorAttributes instance that included the
"exception" attribute , can get the "exception" instance. |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
decorateErrorAttributes(Map<String,Object> errorAttributes,
Map<String,Object> serviceErrorAttributes)
Decorate error attributes, add extension attributes etc.
|
abstract Object |
decorateExceptionCode(Exception exception)
Decorate exception error code, custom for your business logic.
|
abstract String |
decorateExceptionMessage(Exception exception)
Decorate exception message for your self.
|
Map<String,Object> |
getErrorAttributes(org.springframework.web.context.request.WebRequest webRequest,
boolean includeStackTrace)
Returns a
Map of the error attributes. |
getError, getHandlerExecutionException, getMessage, getStatus, resolveException, responseOKpublic AbstractServiceErrorAttributes()
AbstractServiceErrorAttributes instance that included the
"exception" attribute , can get the "exception" instance.public Map<String,Object> getErrorAttributes(org.springframework.web.context.request.WebRequest webRequest, boolean includeStackTrace)
Map of the error attributes. The map can be used as the model of
an error page ModelAndView, or returned as a ResponseBody.getErrorAttributes in interface org.springframework.boot.web.servlet.error.ErrorAttributesgetErrorAttributes in class DefaultErrorAttributesXwebRequest - the source requestincludeStackTrace - if stack trace elements should be includedpublic abstract String decorateExceptionMessage(Exception exception)
exception - the exception that got thrown during handler executionpublic abstract Object decorateExceptionCode(Exception exception)
public Object decorateExceptionCode(Exception exception) {
if (exception instanceof IndexOutOfBoundsException) {
return 123;
}
return super.decorateExceptionCode(exception);
}
exception - the exception that got thrown during handler executionpublic abstract void decorateErrorAttributes(Map<String,Object> errorAttributes, Map<String,Object> serviceErrorAttributes)
errorAttributes that has exception, handler, message,
error, timestamp, status, path params.errorAttributes - error attributesserviceErrorAttributes - service error attributesCopyright © 2021. All rights reserved.