@Override
 public <T extends Throwable> void registerHandlerMethod(HandlerMethod<T> handlerMethod) {
   log.fine(String.format("Adding handler %s to known handlers", handlerMethod));
   if (allHandlers.containsKey(handlerMethod.getExceptionType())) {
     allHandlers.get(handlerMethod.getExceptionType()).add(handlerMethod);
   } else {
     allHandlers.put(
         handlerMethod.getExceptionType(),
         new HashSet<HandlerMethod<? extends Throwable>>(Collections.singleton(handlerMethod)));
   }
 }
  @Override
  public Collection<HandlerMethod<? extends Throwable>> getHandlersForException(
      Type exceptionClass, BeanManager bm, Set<Annotation> handlerQualifiers, boolean isBefore) {
    final Collection<HandlerMethod<? extends Throwable>> returningHandlers =
        new TreeSet<HandlerMethod<? extends Throwable>>(new ExceptionHandlerComparator());
    final HierarchyDiscovery h = new HierarchyDiscovery(exceptionClass);
    final Set<Type> closure = h.getTypeClosure();

    for (Type hierarchyType : closure) {
      if (allHandlers.get(hierarchyType) != null) {
        for (HandlerMethod<?> handler : allHandlers.get(hierarchyType)) {
          if (handler.isBeforeHandler() && isBefore) {
            if (handler.getQualifiers().contains(new AnyLiteral())) {
              returningHandlers.add(handler);
            } else {
              if (!handlerQualifiers.isEmpty()
                  && handlerQualifiers.equals(handler.getQualifiers())) {
                returningHandlers.add(handler);
              }
            }
          } else if (!handler.isBeforeHandler() && !isBefore) {
            if (handler.getQualifiers().contains(new AnyLiteral())) {
              returningHandlers.add(handler);
            } else {
              if (!handlerQualifiers.isEmpty()
                  && handlerQualifiers.equals(handler.getQualifiers())) {
                returningHandlers.add(handler);
              }
            }
          }
        }
      }
    }

    log.fine(
        String.format(
            "Found handlers %s for exception type %s, qualifiers %s",
            returningHandlers, exceptionClass, handlerQualifiers));
    return Collections.unmodifiableCollection(returningHandlers);
  }