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, tools.jackson.databind.json.JsonMapper.Builder jsonMapperBuilder, tools.jackson.dataformat.xml.XmlMapper.Builder xmlMapperBuilder)
    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)
    Determines whether this exception handler is responsible or not.
    org.springframework.web.servlet.ModelAndView
    resolveException(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull jakarta.servlet.http.HttpServletResponse response, Object handler, @NonNull 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, tools.jackson.databind.json.JsonMapper.Builder jsonMapperBuilder, tools.jackson.dataformat.xml.XmlMapper.Builder xmlMapperBuilder)
      Instantiates a new api exception resolver.
      Parameters:
      apiPaths - the api paths
      exceptionMapper - the exception mapper
      jsonMapperBuilder - the json mapper builder
      xmlMapperBuilder - the xml mapper builder
  • 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)
      Determines whether this exception handler is responsible or not.
      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