Class AbstractRestHandlerExceptionResolver
java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
de.hybris.platform.webservicescommons.resolver.AbstractRestHandlerExceptionResolver
- All Implemented Interfaces:
org.springframework.core.Ordered,org.springframework.web.servlet.HandlerExceptionResolver
- Direct Known Subclasses:
RestExceptionResolver,RestHandlerExceptionResolver
public abstract class AbstractRestHandlerExceptionResolver
extends org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
Converts HTTP request using provided list of
HttpMessageConverter.
Class also calculates HTTP status code and error message and sets it to HTTP response.
It also logs information about exception such as message and stacktrace.-
Field Summary
FieldsFields 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 intCalculates HTTP status code.protected ErrorListWsDTOConverts Exception object into list ofErrorWsDTO.protected org.springframework.web.servlet.ModelAndViewdoResolveExceptionInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) protected List<org.springframework.http.MediaType>getAcceptedMediaTypes(org.springframework.http.HttpInputMessage httpInputMessage) Gets accepted media types for HTTP input message.org.springframework.http.converter.HttpMessageConverter<?>[]protected WebserviceErrorFactoryvoidinit()Sets default order for bean if other custom order was not set.voidsetMessageConverters(org.springframework.http.converter.HttpMessageConverter<?>[] messageConverters) voidsetOrder(int order) voidsetWebserviceErrorFactory(WebserviceErrorFactory webserviceErrorFactory) protected booleanCalculates boolean value used to determine if exception stacktrace should be logged.protected org.springframework.web.servlet.ModelAndViewwriteWithMessageConverters(Object returnValue, org.springframework.http.HttpInputMessage inputMessage, org.springframework.http.HttpOutputMessage outputMessage) Writes HTTP input message into HTTP output message.Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, doResolveException, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlers, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
-
Field Details
-
UNDEFINED_ERROR_STATUS
protected static final int UNDEFINED_ERROR_STATUS- See Also:
-
-
Constructor Details
-
AbstractRestHandlerExceptionResolver
public AbstractRestHandlerExceptionResolver()
-
-
Method Details
-
calculateStatusFromException
Calculates HTTP status code.- Parameters:
ex- exception object- Returns:
- HTTP status code
-
shouldDisplayStack
Calculates boolean value used to determine if exception stacktrace should be logged.- Parameters:
ex- exception object- Returns:
- information if exception stacktrace should be logged or not
-
init
@PostConstruct public void init()Sets default order for bean if other custom order was not set. -
doResolveExceptionInternal
-
convertException
Converts Exception object into list ofErrorWsDTO.- Parameters:
ex- exception object- Returns:
- Object with list of
ErrorWsDTO
-
writeWithMessageConverters
protected org.springframework.web.servlet.ModelAndView writeWithMessageConverters(Object returnValue, org.springframework.http.HttpInputMessage inputMessage, org.springframework.http.HttpOutputMessage outputMessage) throws IOException Writes HTTP input message into HTTP output message. HTTP input message is converted using one converter from list ofHttpMessageConverter.- Parameters:
returnValue- object to which should be HTTP input message convertedinputMessage- object for conversionoutputMessage- object for which converted value is written- Returns:
ModelAndViewobject with converted HTTP input message- Throws:
IOException
-
getAcceptedMediaTypes
protected List<org.springframework.http.MediaType> getAcceptedMediaTypes(org.springframework.http.HttpInputMessage httpInputMessage) Gets accepted media types for HTTP input message.- Parameters:
httpInputMessage- HTTP input message- Returns:
- list of accepted media types for HTTP input message
-
setOrder
public void setOrder(int order) - Overrides:
setOrderin classorg.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
-
getMessageConverters
public org.springframework.http.converter.HttpMessageConverter<?>[] getMessageConverters() -
setMessageConverters
public void setMessageConverters(org.springframework.http.converter.HttpMessageConverter<?>[] messageConverters) -
getWebserviceErrorFactory
-
setWebserviceErrorFactory
-