code: public static boolean checkClassIsDefinedInThrowsException(Class[] classes, Throwable thrownException) {
  
          // return false if either passed classes array or thrownException are null.
          if (classes == null || thrownException == null) {
              return false;
          }
  
          // loop through classes array to check for matching type
          for (Class clazz : classes) {
  
              if (clazz.isInstance(thrownException)) {
                  return true;
              }
  
          }
  
          return false;
      }
docs: Checks whether the passed Throwable is defined included in passed classes array or is subtype of one of the included classes.
  
  @param classes the classes to search
  @param thrownException the Throwable which must be searched for
  @return true if Throwable was found, otherwise false