类 ExceptionHandlerMethodResolver

java.lang.Object
cn.taketoday.web.handler.method.ExceptionHandlerMethodResolver

public class ExceptionHandlerMethodResolver extends 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.
从以下版本开始:
4.0 2022/3/2 22:12
作者:
Rossen Stoyanchev, Juergen Hoeller, Sam Brannen, Harry Yang
  • 字段详细资料

    • EXCEPTION_HANDLER_METHODS

      public static final cn.taketoday.util.ReflectionUtils.MethodFilter EXCEPTION_HANDLER_METHODS
      A filter for selecting @ExceptionHandler methods.
    • NO_MATCHING_EXCEPTION_HANDLER_METHOD

      private static final Method NO_MATCHING_EXCEPTION_HANDLER_METHOD
    • mappedMethods

      private final Map<Class<? extends Throwable>,Method> mappedMethods
    • exceptionLookupCache

      private final Map<Class<? extends Throwable>,Method> exceptionLookupCache
  • 构造器详细资料

    • ExceptionHandlerMethodResolver

      public ExceptionHandlerMethodResolver(Class<?> handlerType)
      A constructor that finds ExceptionHandler methods in the given type.
      参数:
      handlerType - the type to introspect
  • 方法详细资料

    • detectExceptionMappings

      private List<Class<? extends Throwable>> detectExceptionMappings(Method method)
      Extract exception mappings from the @ExceptionHandler annotation first, and then as a fallback from the method signature itself.
    • detectAnnotationExceptionMappings

      private void detectAnnotationExceptionMappings(Method method, List<Class<? extends Throwable>> result)
    • addExceptionMapping

      private void addExceptionMapping(Class<? extends Throwable> exceptionType, Method method)
    • hasExceptionMappings

      public boolean hasExceptionMappings()
      Whether the contained type has any exception mappings.
    • resolveMethod

      @Nullable public Method resolveMethod(Throwable exception)
      Find a Method to handle the given exception.

      Uses ExceptionDepthComparator if more than one match is found.

      参数:
      exception - the exception
      返回:
      a Method to handle the exception, or null if none found
    • resolveMethodByThrowable

      @Nullable public Method resolveMethodByThrowable(Throwable exception)
      Find a Method to handle the given Throwable.

      Uses ExceptionDepthComparator if more than one match is found.

      参数:
      exception - the exception
      返回:
      a Method to handle the exception, or null if none found
    • resolveMethodByExceptionType

      @Nullable public Method resolveMethodByExceptionType(Class<? extends 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).

      Uses ExceptionDepthComparator if more than one match is found.

      参数:
      exceptionType - the exception type
      返回:
      a Method to handle the exception, or null if none found
    • getMappedMethod

      private Method getMappedMethod(Class<? extends Throwable> exceptionType)
      Return the Method mapped to the given exception type, or NO_MATCHING_EXCEPTION_HANDLER_METHOD if none.
    • noMatchingExceptionHandler

      private void noMatchingExceptionHandler()