Class RestExceptionResolver
java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
de.hybris.platform.webservicescommons.resolver.AbstractRestHandlerExceptionResolver
de.hybris.platform.webservicescommons.resolver.RestExceptionResolver
- All Implemented Interfaces:
org.springframework.core.Ordered,org.springframework.web.servlet.HandlerExceptionResolver
Exception resolver implementation for RESTful Web services. Resolver sets error status and message in the response, that can be customized based on configuration.
Class internally uses FallbackConfigurationHelper to get configuration values. Configuration is defined on 3 levels: specified extension, webservicescommons or default.
In first place configuration is taken from specified extension. In second place configuration is taken from webservicescommons (if extension configuration is not defined).
If configuration is not defined then exception stacktrace is logged and default value of status and error message is set.
-
Field Summary
Fields inherited from class de.hybris.platform.webservicescommons.resolver.AbstractRestHandlerExceptionResolver
UNDEFINED_ERROR_STATUSFields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ExceptionMessageFormatterTypeCalculates exception message formatter type.protected intCalculates HTTP status code.protected ErrorListWsDTOConverts Exception object into list ofErrorWsDTO.protected org.springframework.web.servlet.ModelAndViewdoResolveException(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Object handler, Exception ex) protected Stringprotected FallbackConfigurationHelperprotected voidsetErrorMessages(Exception ex, ErrorListWsDTO errorListDto) Sets formatted error message to each error from list.voidsetExceptionMapping(Map<ExceptionMessageFormatterType, AbstractExceptionMessageFormatter> exceptionMapping) voidsetExtensionName(String extensionName) voidsetFallbackConfigurationHelper(FallbackConfigurationHelper fallbackConfigurationHelper) protected booleanCalculates boolean value used to determine if exception stacktrace should be logged.Methods inherited from class de.hybris.platform.webservicescommons.resolver.AbstractRestHandlerExceptionResolver
doResolveExceptionInternal, getAcceptedMediaTypes, getMessageConverters, getWebserviceErrorFactory, init, setMessageConverters, setOrder, setWebserviceErrorFactory, writeWithMessageConvertersMethods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlers, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
-
Constructor Details
-
RestExceptionResolver
public RestExceptionResolver()
-
-
Method Details
-
calculateStatusFromException
Description copied from class:AbstractRestHandlerExceptionResolverCalculates HTTP status code.- Overrides:
calculateStatusFromExceptionin classAbstractRestHandlerExceptionResolver- Parameters:
ex- exception object- Returns:
- HTTP status code
-
shouldDisplayStack
Description copied from class:AbstractRestHandlerExceptionResolverCalculates boolean value used to determine if exception stacktrace should be logged.- Overrides:
shouldDisplayStackin classAbstractRestHandlerExceptionResolver- Parameters:
ex- exception object- Returns:
- information if exception stacktrace should be logged or not
-
convertException
Description copied from class:AbstractRestHandlerExceptionResolverConverts Exception object into list ofErrorWsDTO.- Overrides:
convertExceptionin classAbstractRestHandlerExceptionResolver- Parameters:
ex- exception object- Returns:
- Object with list of
ErrorWsDTO
-
doResolveException
protected org.springframework.web.servlet.ModelAndView doResolveException(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Object handler, Exception ex) - Specified by:
doResolveExceptionin classorg.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
-
setErrorMessages
Sets formatted error message to each error from list.Method internally uses message formatter defined in configuration.
- Parameters:
ex- exception objecterrorListDto- list of Webservices errors for which message is formatted and set
-
calculateExceptionMessageFormatter
Calculates exception message formatter type.- Parameters:
ex- exception object- Returns:
- exception message formatter type
-
getExceptionMapping
protected Map<ExceptionMessageFormatterType,AbstractExceptionMessageFormatter> getExceptionMapping() -
setExceptionMapping
public void setExceptionMapping(Map<ExceptionMessageFormatterType, AbstractExceptionMessageFormatter> exceptionMapping) -
getFallbackConfigurationHelper
-
setFallbackConfigurationHelper
-
getExtensionName
-
setExtensionName
-