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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    The empty view.
  • Field Summary

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

    Constructors
    Constructor
    Description
    ApiExceptionResolver(List<String> apiPaths, org.bremersee.exception.RestApiExceptionMapper exceptionMapper)
    Instantiates a new api exception resolver.
    ApiExceptionResolver(List<String> apiPaths, 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(List<String> apiPaths, org.bremersee.exception.RestApiExceptionMapper exceptionMapper, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder)
    Instantiates a new api exception resolver.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    applyStatusCodeIfPossible(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int statusCode)
    Apply status code if possible.
    protected boolean
    isExceptionHandlerResponsible(jakarta.servlet.http.HttpServletRequest request, Object handler)
    Is this exception handler responsible.
    org.springframework.web.servlet.ModelAndView
    resolveException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, Exception ex)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ApiExceptionResolver

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

      public ApiExceptionResolver(List<String> apiPaths, org.bremersee.exception.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, 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:
      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