Class ExceptionHandlerMethodResolver
- java.lang.Object
- org.springframework.web.method.annotation.ExceptionHandlerMethodResolver
public class ExceptionHandlerMethodResolver extends Object
Discovers @ExceptionHandler methods in a given class, including all of its superclasses, and helps to resolve a givenExceptionto the exception types supported by a givenMethod.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller
Field Summary
Fields Modifier and Type Field Description static ReflectionUtils.MethodFilterEXCEPTION_HANDLER_METHODSA filter for selecting@ExceptionHandlermethods.
Constructor Summary
Constructors Constructor Description ExceptionHandlerMethodResolver(Class<?> handlerType)A constructor that findsExceptionHandlermethods in the given type.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasExceptionMappings()Whether the contained type has any exception mappings.MethodresolveMethod(Exception exception)Find aMethodto handle the given exception.MethodresolveMethodByExceptionType(Class<? extends Throwable> exceptionType)Find aMethodto handle the given exception type.MethodresolveMethodByThrowable(Throwable exception)Find aMethodto handle the given Throwable.
Field Detail
EXCEPTION_HANDLER_METHODS
public static final ReflectionUtils.MethodFilter EXCEPTION_HANDLER_METHODS
A filter for selecting@ExceptionHandlermethods.
Constructor Detail
ExceptionHandlerMethodResolver
public ExceptionHandlerMethodResolver(Class<?> handlerType)
A constructor that findsExceptionHandlermethods in the given type.- Parameters:
handlerType- the type to introspect
Method Detail
hasExceptionMappings
public boolean hasExceptionMappings()
Whether the contained type has any exception mappings.
resolveMethod
@Nullable public Method resolveMethod(Exception exception)
Find aMethodto handle the given exception. UseExceptionDepthComparatorif more than one match is found.- Parameters:
exception- the exception- Returns:
- a Method to handle the exception, or
nullif none found
resolveMethodByThrowable
@Nullable public Method resolveMethodByThrowable(Throwable exception)
Find aMethodto handle the given Throwable. UseExceptionDepthComparatorif 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
@Nullable public Method resolveMethodByExceptionType(Class<? extends Throwable> exceptionType)
Find aMethodto handle the given exception type. This can be useful if anExceptioninstance is not available (e.g. for tools).- Parameters:
exceptionType- the exception type- Returns:
- a Method to handle the exception, or
nullif none found