ExceptionHandlerExceptionResolver
@Deprecated public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExceptionResolver
HandlerExceptionResolver
interface that handles
exceptions through the ExceptionHandler
annotation.
This exception resolver is enabled by default in the DispatcherServlet
.
Modifier and Type | Field and Description |
---|---|
private WebArgumentResolver[] |
customArgumentResolvers
Deprecated.
|
private java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method>> |
exceptionHandlerCache
Deprecated.
|
private HttpMessageConverter<?>[] |
messageConverters
Deprecated.
|
private static java.lang.reflect.Method |
NO_METHOD_FOUND
Deprecated.
|
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AnnotationMethodHandlerExceptionResolver()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.Object |
doInvokeMethod(java.lang.reflect.Method method,
java.lang.Object target,
java.lang.Object[] args)
Deprecated.
|
protected ModelAndView |
doResolveException(HttpServletRequest request,
HttpServletResponse response,
java.lang.Object handler,
java.lang.Exception ex)
Deprecated.
Actually resolve the given exception that got thrown during on handler execution,
returning a ModelAndView that represents a specific error page if appropriate.
|
private java.lang.reflect.Method |
findBestExceptionHandlerMethod(java.lang.Object handler,
java.lang.Exception thrownException)
Deprecated.
Finds the handler method that matches the thrown exception best.
|
private java.lang.reflect.Method |
getBestMatchingMethod(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> resolverMethods,
java.lang.Exception thrownException)
Deprecated.
Uses the
DepthComparator to find the best matching method |
protected java.util.List<java.lang.Class<? extends java.lang.Throwable>> |
getHandledExceptions(java.lang.reflect.Method method)
Deprecated.
Returns all the exception classes handled by the given method.
|
private ModelAndView |
getModelAndView(java.lang.reflect.Method handlerMethod,
java.lang.Object returnValue,
ServletWebRequest webRequest)
Deprecated.
|
private ModelAndView |
handleResponseBody(java.lang.Object returnValue,
ServletWebRequest webRequest)
Deprecated.
|
protected java.lang.Object |
resolveCommonArgument(MethodParameter methodParameter,
NativeWebRequest webRequest,
java.lang.Exception thrownException)
Deprecated.
Resolves common method arguments.
|
private java.lang.Object[] |
resolveHandlerArguments(java.lang.reflect.Method handlerMethod,
java.lang.Object handler,
NativeWebRequest webRequest,
java.lang.Exception thrownException)
Deprecated.
Resolves the arguments for the given method.
|
protected java.lang.Object |
resolveStandardArgument(java.lang.Class<?> parameterType,
NativeWebRequest webRequest,
java.lang.Exception thrownException)
Deprecated.
Resolves standard method arguments.
|
void |
setCustomArgumentResolver(WebArgumentResolver argumentResolver)
Deprecated.
Set a custom ArgumentResolvers to use for special method parameter types.
|
void |
setCustomArgumentResolvers(WebArgumentResolver[] argumentResolvers)
Deprecated.
Set one or more custom ArgumentResolvers to use for special method parameter types.
|
void |
setMessageConverters(HttpMessageConverter<?>[] messageConverters)
Deprecated.
Set the message body converters to use.
|
buildLogMessage, getOrder, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
private static final java.lang.reflect.Method NO_METHOD_FOUND
private final java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method>> exceptionHandlerCache
private WebArgumentResolver[] customArgumentResolvers
private HttpMessageConverter<?>[] messageConverters
public AnnotationMethodHandlerExceptionResolver()
public void setCustomArgumentResolver(WebArgumentResolver argumentResolver)
Such a custom ArgumentResolver will kick in first, having a chance to resolve an argument value before the standard argument handling kicks in.
public void setCustomArgumentResolvers(WebArgumentResolver[] argumentResolvers)
Any such custom ArgumentResolver will kick in first, having a chance to resolve an argument value before the standard argument handling kicks in.
public void setMessageConverters(HttpMessageConverter<?>[] messageConverters)
These converters are used to convert from and to HTTP requests and responses.
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
AbstractHandlerExceptionResolver
May be overridden in subclasses, in order to apply specific exception checks. Note that this template method will be invoked after checking whether this resolved applies ("mappedHandlers" etc), so an implementation may simply proceed with its actual exception handling.
doResolveException
in class AbstractHandlerExceptionResolver
request
- current HTTP requestresponse
- current HTTP responsehandler
- the executed handler, or null
if none chosen at the time
of the exception (for example, if multipart resolution failed)ex
- the exception that got thrown during handler executionnull
for default processingprivate java.lang.reflect.Method findBestExceptionHandlerMethod(java.lang.Object handler, java.lang.Exception thrownException)
handler
- the handler objectthrownException
- the exception to be handlednull
if none is foundprotected java.util.List<java.lang.Class<? extends java.lang.Throwable>> getHandledExceptions(java.lang.reflect.Method method)
The default implementation looks for exceptions in the annotation,
or - if that annotation element is empty - any exceptions listed in the method parameters if the method
is annotated with @ExceptionHandler
.
method
- the methodprivate java.lang.reflect.Method getBestMatchingMethod(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> resolverMethods, java.lang.Exception thrownException)
DepthComparator
to find the best matching methodnull
.private java.lang.Object[] resolveHandlerArguments(java.lang.reflect.Method handlerMethod, java.lang.Object handler, NativeWebRequest webRequest, java.lang.Exception thrownException) throws java.lang.Exception
resolveCommonArgument(org.springframework.core.MethodParameter, org.springframework.web.context.request.NativeWebRequest, java.lang.Exception)
.java.lang.Exception
protected java.lang.Object resolveCommonArgument(MethodParameter methodParameter, NativeWebRequest webRequest, java.lang.Exception thrownException) throws java.lang.Exception
argumentResolvers
first, then checking resolveStandardArgument(java.lang.Class<?>, org.springframework.web.context.request.NativeWebRequest, java.lang.Exception)
.methodParameter
- the method parameterwebRequest
- the requestthrownException
- the exception thrownWebArgumentResolver.UNRESOLVED
java.lang.Exception
protected java.lang.Object resolveStandardArgument(java.lang.Class<?> parameterType, NativeWebRequest webRequest, java.lang.Exception thrownException) throws java.lang.Exception
NativeWebRequest
,
ServletRequest
, ServletResponse
, HttpSession
, Principal
,
Locale
, request InputStream
, request Reader
, response OutputStream
,
response Writer
, and the given thrownException
.parameterType
- the method parameter typewebRequest
- the requestthrownException
- the exception thrownWebArgumentResolver.UNRESOLVED
java.lang.Exception
private java.lang.Object doInvokeMethod(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] args) throws java.lang.Exception
java.lang.Exception
private ModelAndView getModelAndView(java.lang.reflect.Method handlerMethod, java.lang.Object returnValue, ServletWebRequest webRequest) throws java.lang.Exception
java.lang.Exception
private ModelAndView handleResponseBody(java.lang.Object returnValue, ServletWebRequest webRequest) throws ServletException, java.io.IOException
ServletException
java.io.IOException