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
public class RestExceptionResolver extends AbstractRestHandlerExceptionResolver
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
FallbackConfigurationHelperto 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_STATUS
-
-
Constructor Summary
Constructors Constructor Description RestExceptionResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ExceptionMessageFormatterTypecalculateExceptionMessageFormatter(java.lang.Exception ex)Calculates exception message formatter type.protected intcalculateStatusFromException(java.lang.Exception ex)Calculates HTTP status code.protected ErrorListWsDTOconvertException(java.lang.Exception ex)Converts Exception object into list ofErrorWsDTO.protected org.springframework.web.servlet.ModelAndViewdoResolveException(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, java.lang.Object handler, java.lang.Exception ex)protected java.util.Map<ExceptionMessageFormatterType,AbstractExceptionMessageFormatter>getExceptionMapping()protected java.lang.StringgetExtensionName()protected FallbackConfigurationHelpergetFallbackConfigurationHelper()protected voidsetErrorMessages(java.lang.Exception ex, ErrorListWsDTO errorListDto)Sets formatted error message to each error from list.voidsetExceptionMapping(java.util.Map<ExceptionMessageFormatterType,AbstractExceptionMessageFormatter> exceptionMapping)voidsetExtensionName(java.lang.String extensionName)voidsetFallbackConfigurationHelper(FallbackConfigurationHelper fallbackConfigurationHelper)protected booleanshouldDisplayStack(java.lang.Exception ex)Calculates 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, writeWithMessageConverters
-
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlers, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
-
-
-
-
Method Detail
-
calculateStatusFromException
protected int calculateStatusFromException(java.lang.Exception ex)
Description copied from class:AbstractRestHandlerExceptionResolverCalculates HTTP status code.- Overrides:
calculateStatusFromExceptionin classAbstractRestHandlerExceptionResolver- Parameters:
ex- exception object- Returns:
- HTTP status code
-
shouldDisplayStack
protected boolean shouldDisplayStack(java.lang.Exception ex)
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
protected ErrorListWsDTO convertException(java.lang.Exception ex)
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, java.lang.Object handler, java.lang.Exception ex)- Specified by:
doResolveExceptionin classorg.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
-
setErrorMessages
protected void setErrorMessages(java.lang.Exception ex, ErrorListWsDTO errorListDto)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
protected ExceptionMessageFormatterType calculateExceptionMessageFormatter(java.lang.Exception ex)
Calculates exception message formatter type.- Parameters:
ex- exception object- Returns:
- exception message formatter type
-
getExceptionMapping
protected java.util.Map<ExceptionMessageFormatterType,AbstractExceptionMessageFormatter> getExceptionMapping()
-
setExceptionMapping
public void setExceptionMapping(java.util.Map<ExceptionMessageFormatterType,AbstractExceptionMessageFormatter> exceptionMapping)
-
getFallbackConfigurationHelper
protected FallbackConfigurationHelper getFallbackConfigurationHelper()
-
setFallbackConfigurationHelper
public void setFallbackConfigurationHelper(FallbackConfigurationHelper fallbackConfigurationHelper)
-
getExtensionName
protected java.lang.String getExtensionName()
-
setExtensionName
public void setExtensionName(java.lang.String extensionName)
-
-