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 ; }
Checks whether the passed Throwable is defined included in passed classes array or is subtype of one of the included classes .