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 Details

    • UNDEFINED_ERROR_STATUS

      protected static final int UNDEFINED_ERROR_STATUS
      See Also:
  • Constructor Details

    • AbstractRestHandlerExceptionResolver

      public AbstractRestHandlerExceptionResolver()
  • Method Details

    • calculateStatusFromException

      protected int calculateStatusFromException(Exception ex)
      Calculates HTTP status code.
      Parameters:
      ex - exception object
      Returns:
      HTTP status code
    • shouldDisplayStack

      protected boolean shouldDisplayStack(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, Object handler, Exception ex)
    • convertException

      protected ErrorListWsDTO convertException(Exception ex)
      Converts Exception object into list of ErrorWsDTO.
      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 of HttpMessageConverter.
      Parameters:
      returnValue - object to which should be HTTP input message converted
      inputMessage - object for conversion
      outputMessage - object for which converted value is written
      Returns:
      ModelAndView object 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:
      setOrder in class org.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)