Class ApiExceptionResolver

java.lang.Object
org.bremersee.exception.servlet.ApiExceptionResolver
All Implemented Interfaces:
org.springframework.web.servlet.HandlerExceptionResolver

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

  • Constructor Details

    • ApiExceptionResolver

      public ApiExceptionResolver(List<String> apiPaths, RestApiExceptionMapper exceptionMapper)
      Instantiates a new api exception resolver.
      Parameters:
      apiPaths - the api paths
      exceptionMapper - the exception mapper
    • ApiExceptionResolver

      public ApiExceptionResolver(List<String> apiPaths, RestApiExceptionMapper exceptionMapper, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder)
      Instantiates a new api exception resolver.
      Parameters:
      apiPaths - the api paths
      exceptionMapper - the exception mapper
      objectMapperBuilder - the object mapper builder
    • ApiExceptionResolver

      public ApiExceptionResolver(List<String> apiPaths, RestApiExceptionMapper exceptionMapper, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
      Instantiates a new api exception resolver.
      Parameters:
      apiPaths - the api paths
      exceptionMapper - the exception mapper
      objectMapper - the object mapper
      xmlMapper - the xml mapper
  • Method Details

    • resolveException

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

      protected boolean isExceptionHandlerResponsible(jakarta.servlet.http.HttpServletRequest request, 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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int statusCode)
      Apply status code if possible.
      Parameters:
      request - the request
      response - the response
      statusCode - the status code