code: public static boolean containsThrowableOfType(Throwable throwable, Class<?>... throwableTypes) {
          List<Throwable> alreadyProcessedThrowables = new ArrayList<Throwable>();
          while (true) {
              if (throwable == null) {
                  // end of the list of causes
                  return false;
              } else if (alreadyProcessedThrowables.contains(throwable)) {
                  // infinite loop in causes
                  return false;
              } else {
                  for (Class<?> throwableType : throwableTypes) {
                      if (throwableType.isAssignableFrom(throwable.getClass())) {
                          return true;
                      }
                  }
                  alreadyProcessedThrowables.add(throwable);
                  throwable = throwable.getCause();
              }
          }
      }
docs: Returns <code>true</code> if the given <code>throwable</code> or one of
  its cause is an instance of one of the given <code>throwableTypes</code>.