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.AbstractHandlerExceptionResolverConverts HTTP request using provided list ofHttpMessageConverter. 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
Fields Modifier and Type Field Description protected static intUNDEFINED_ERROR_STATUS
-
Constructor Summary
Constructors Constructor Description AbstractRestHandlerExceptionResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.ModelAndViewdoResolveExceptionInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)protected java.util.List<org.springframework.http.MediaType>getAcceptedMediaTypes(org.springframework.http.HttpInputMessage httpInputMessage)Gets accepted media types for HTTP input message.org.springframework.http.converter.HttpMessageConverter<?>[]getMessageConverters()protected WebserviceErrorFactorygetWebserviceErrorFactory()voidinit()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 booleanshouldDisplayStack(java.lang.Exception ex)Calculates boolean value used to determine if exception stacktrace should be logged.protected org.springframework.web.servlet.ModelAndViewwriteWithMessageConverters(java.lang.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 Detail
-
UNDEFINED_ERROR_STATUS
protected static final int UNDEFINED_ERROR_STATUS
- See Also:
- Constant Field Values
-
-
Method Detail
-
calculateStatusFromException
protected int calculateStatusFromException(java.lang.Exception ex)
Calculates HTTP status code.- Parameters:
ex- exception object- Returns:
- HTTP status code
-
shouldDisplayStack
protected boolean shouldDisplayStack(java.lang.Exception ex)
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
protected org.springframework.web.servlet.ModelAndView doResolveExceptionInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
-
convertException
protected ErrorListWsDTO convertException(java.lang.Exception ex)
Converts Exception object into list ofErrorWsDTO.- Parameters:
ex- exception object- Returns:
- Object with list of
ErrorWsDTO
-
writeWithMessageConverters
protected org.springframework.web.servlet.ModelAndView writeWithMessageConverters(java.lang.Object returnValue, org.springframework.http.HttpInputMessage inputMessage, org.springframework.http.HttpOutputMessage outputMessage) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
getAcceptedMediaTypes
protected java.util.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
protected WebserviceErrorFactory getWebserviceErrorFactory()
-
setWebserviceErrorFactory
public void setWebserviceErrorFactory(WebserviceErrorFactory webserviceErrorFactory)
-
-