Package org.bremersee.exception.servlet
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
Modifier and TypeClassDescriptionprotected static class
The empty view. -
Field Summary
-
Constructor Summary
ConstructorDescriptionApiExceptionResolver
(List<String> apiPaths, RestApiExceptionMapper exceptionMapper) Instantiates a new api exception resolver.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.ApiExceptionResolver
(List<String> apiPaths, RestApiExceptionMapper exceptionMapper, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder) Instantiates a new api exception resolver. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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)
-
Field Details
-
MODEL_KEY
The constant MODEL_KEY.- See Also:
-
-
Constructor Details
-
ApiExceptionResolver
Instantiates a new api exception resolver.- Parameters:
apiPaths
- the api pathsexceptionMapper
- 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 pathsexceptionMapper
- the exception mapperobjectMapperBuilder
- 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 pathsexceptionMapper
- the exception mapperobjectMapper
- the object mapperxmlMapper
- 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 interfaceorg.springframework.web.servlet.HandlerExceptionResolver
-
isExceptionHandlerResponsible
protected boolean isExceptionHandlerResponsible(jakarta.servlet.http.HttpServletRequest request, Object handler) Is this exception handler responsible.- Parameters:
request
- the requesthandler
- the handler- Returns:
true
if it is responsible, otherwisefalse
-
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 requestresponse
- the responsestatusCode
- the status code
-