org.springframework.web.method.annotation

Class ExceptionHandlerMethodResolver

  • java.lang.Object
    • org.springframework.web.method.annotation.ExceptionHandlerMethodResolver


  • public class ExceptionHandlerMethodResolver
    extends java.lang.Object
    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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean hasExceptionMappings()
      Whether the contained type has any exception mappings.
      java.lang.reflect.Method resolveMethod(java.lang.Exception exception)
      Find a Method to handle the given exception.
      java.lang.reflect.Method resolveMethodByExceptionType(java.lang.Class<? extends java.lang.Throwable> exceptionType)
      Find a Method to handle the given exception type.
      java.lang.reflect.Method resolveMethodByThrowable(java.lang.Throwable exception)
      Find a Method to handle the given Throwable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXCEPTION_HANDLER_METHODS

        public static final ReflectionUtils.MethodFilter EXCEPTION_HANDLER_METHODS
        A filter for selecting @ExceptionHandler methods.
    • Constructor Detail

      • ExceptionHandlerMethodResolver

        public ExceptionHandlerMethodResolver(java.lang.Class<?> handlerType)
        A constructor that finds ExceptionHandler methods 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 java.lang.reflect.Method resolveMethod(java.lang.Exception exception)
        Find a Method to handle the given exception. Use 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

        @Nullable
        public java.lang.reflect.Method resolveMethodByThrowable(java.lang.Throwable exception)
        Find a Method to handle the given Throwable. Use 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

        @Nullable
        public java.lang.reflect.Method resolveMethodByExceptionType(java.lang.Class<? extends java.lang.Throwable> exceptionType)
        Find a Method to handle the given exception type. This can be useful if an Exception instance is not available (e.g. for tools).
        Parameters:
        exceptionType - the exception type
        Returns:
        a Method to handle the exception, or null if none found