code: @GwtIncompatible("incompatible method")
      public static boolean hasCause(Throwable chain,
              final Class<? extends Throwable> type) {
          if (chain instanceof UndeclaredThrowableException) {
              chain = chain.getCause();
          }
          return type.isInstance(chain);
      }
docs: Does the throwable's causal chain have an immediate or wrapped exception
  of the given type?
  
  @param chain
  The root of a Throwable causal chain.
  @param type
  The exception type to test.
  @return true, if chain is an instance of type or is an
  UndeclaredThrowableException wrapping a cause.
  @since 3.5
  @see #wrapAndThrow(Throwable)