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
FieldsModifier and TypeFieldDescriptionstatic final ReflectionUtils.MethodFilterA filter for selecting@ExceptionHandlermethods. -
Constructor Summary
ConstructorsConstructorDescriptionExceptionHandlerMethodResolver(Class<?> handlerType) A constructor that findsExceptionHandlermethods in the given type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the contained type has any exception mappings.resolveMethod(Exception exception) Find aMethodto handle the given exception.resolveMethodByExceptionType(Class<? extends Throwable> exceptionType) Find aMethodto handle the given exception type.resolveMethodByThrowable(Throwable exception) Find aMethodto handle the given Throwable.
-
Field Details
-
EXCEPTION_HANDLER_METHODS
A filter for selecting@ExceptionHandlermethods.
-
-
Constructor Details
-
ExceptionHandlerMethodResolver
A constructor that findsExceptionHandlermethods 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 aMethodto handle the given exception.Uses
ExceptionDepthComparatorif more than one match is found.- Parameters:
exception- the exception- Returns:
- a Method to handle the exception, or
nullif none found
-
resolveMethodByThrowable
Find aMethodto handle the given Throwable.Uses
ExceptionDepthComparatorif more than one match is found.- Parameters:
exception- the exception- Returns:
- a Method to handle the exception, or
nullif none found - Since:
- 5.0
-
resolveMethodByExceptionType
Find aMethodto handle the given exception type. This can be useful if anExceptioninstance is not available (e.g. for tools).Uses
ExceptionDepthComparatorif more than one match is found.- Parameters:
exceptionType- the exception type- Returns:
- a Method to handle the exception, or
nullif none found
-