Class ExceptionHandlerMethodResolver
java.lang.Object
org.springframework.web.method.annotation.ExceptionHandlerMethodResolver
Discovers @ExceptionHandler methods in a given class,
including all of its superclasses, and helps to resolve a given
Exception
to the exception types supported by a given Method
.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ReflectionUtils.MethodFilter
A filter for selecting@ExceptionHandler
methods. -
Constructor Summary
ConstructorDescriptionExceptionHandlerMethodResolver
(Class<?> handlerType) A constructor that findsExceptionHandler
methods in the given type. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the contained type has any exception mappings.resolveMethod
(Exception exception) Find aMethod
to handle the given exception.resolveMethodByExceptionType
(Class<? extends Throwable> exceptionType) Find aMethod
to handle the given exception type.resolveMethodByThrowable
(Throwable exception) Find aMethod
to handle the given Throwable.
-
Field Details
-
EXCEPTION_HANDLER_METHODS
A filter for selecting@ExceptionHandler
methods.
-
-
Constructor Details
-
ExceptionHandlerMethodResolver
A constructor that findsExceptionHandler
methods in the given type.- Parameters:
handlerType
- the type to introspect
-
-
Method Details
-
hasExceptionMappings
public boolean hasExceptionMappings()Whether the contained type has any exception mappings. -
resolveMethod
Find aMethod
to handle the given exception.Uses
ExceptionDepthComparator
if more than one match is found.- Parameters:
exception
- the exception- Returns:
- a Method to handle the exception, or
null
if none found
-
resolveMethodByThrowable
Find aMethod
to handle the given Throwable.Uses
ExceptionDepthComparator
if more than one match is found.- Parameters:
exception
- the exception- Returns:
- a Method to handle the exception, or
null
if none found - Since:
- 5.0
-
resolveMethodByExceptionType
Find aMethod
to handle the given exception type. This can be useful if anException
instance is not available (e.g. for tools).Uses
ExceptionDepthComparator
if more than one match is found.- Parameters:
exceptionType
- the exception type- Returns:
- a Method to handle the exception, or
null
if none found
-