Class ApiExceptionResolver

  • All Implemented Interfaces:
    org.springframework.web.servlet.HandlerExceptionResolver

    @Validated
    public class ApiExceptionResolver
    extends Object
    implements org.springframework.web.servlet.HandlerExceptionResolver
    The api exception resolver.
    Author:
    Christian Bremer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static String MODEL_KEY
      The constant MODEL_KEY.
    • Constructor Summary

      Constructors 
      Constructor Description
      ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper)
      Instantiates a new api exception resolver.
      ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
      Instantiates a new api exception resolver.
      ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder)
      Instantiates a new api exception resolver.
    • Constructor Detail

      • ApiExceptionResolver

        public ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper)
        Instantiates a new api exception resolver.
        Parameters:
        exceptionMapper - the exception mapper
      • ApiExceptionResolver

        public ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper,
                                    org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder)
        Instantiates a new api exception resolver.
        Parameters:
        exceptionMapper - the exception mapper
        objectMapperBuilder - the object mapper builder
      • ApiExceptionResolver

        public ApiExceptionResolver​(org.bremersee.exception.RestApiExceptionMapper exceptionMapper,
                                    com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                    com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
        Instantiates a new api exception resolver.
        Parameters:
        exceptionMapper - the exception mapper
        objectMapper - the object mapper
        xmlMapper - the xml mapper
    • Method Detail

      • resolveException

        public org.springframework.web.servlet.ModelAndView resolveException​(@NonNull
                                                                             javax.servlet.http.HttpServletRequest request,
                                                                             @NonNull
                                                                             javax.servlet.http.HttpServletResponse response,
                                                                             @Nullable
                                                                             Object handler,
                                                                             @NonNull
                                                                             Exception ex)
        Specified by:
        resolveException in interface org.springframework.web.servlet.HandlerExceptionResolver
      • isExceptionHandlerResponsible

        protected boolean isExceptionHandlerResponsible​(javax.servlet.http.HttpServletRequest request,
                                                        @Nullable
                                                        Object handler)
        Is this exception handler responsible.
        Parameters:
        request - the request
        handler - the handler
        Returns:
        true if it is responsible, otherwise false
      • applyStatusCodeIfPossible

        protected final void applyStatusCodeIfPossible​(javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response,
                                                       int statusCode)
        Apply status code if possible.
        Parameters:
        request - the request
        response - the response
        statusCode - the status code