public class ExceptionHandlerMethodResolver extends Object
Exception
to the exception types supported by a given Method
.Modifier and Type | Field and Description |
---|---|
static ReflectionUtils.MethodFilter |
EXCEPTION_HANDLER_METHODS
A filter for selecting
@ExceptionHandler methods. |
Constructor and Description |
---|
ExceptionHandlerMethodResolver(Class<?> handlerType)
A constructor that finds
ExceptionHandler methods in the given type. |
Modifier and Type | Method and Description |
---|---|
boolean |
hasExceptionMappings()
Whether the contained type has any exception mappings.
|
Method |
resolveMethod(Exception exception)
Find a
Method to handle the given exception. |
Method |
resolveMethodByExceptionType(Class<? extends Throwable> exceptionType)
Find a
Method to handle the given exception type. |
Method |
resolveMethodByThrowable(Throwable exception)
Find a
Method to handle the given Throwable. |
public static final ReflectionUtils.MethodFilter EXCEPTION_HANDLER_METHODS
@ExceptionHandler
methods.public ExceptionHandlerMethodResolver(Class<?> handlerType)
ExceptionHandler
methods in the given type.handlerType
- the type to introspectpublic boolean hasExceptionMappings()
@Nullable public Method resolveMethod(Exception exception)
Method
to handle the given exception.
Uses ExceptionDepthComparator
if more than one match is found.
exception
- the exceptionnull
if none found@Nullable public Method resolveMethodByThrowable(Throwable exception)
Method
to handle the given Throwable.
Uses ExceptionDepthComparator
if more than one match is found.
exception
- the exceptionnull
if none found@Nullable public Method resolveMethodByExceptionType(Class<? extends Throwable> exceptionType)
Method
to handle the given exception type. This can be
useful if an Exception
instance is not available (e.g. for tools).
Uses ExceptionDepthComparator
if more than one match is found.
exceptionType
- the exception typenull
if none found