public static boolean expectedCause ( final Exception actualException , final Collection < Class < ? extends Exception > > expectedExceptions ) { checkNotNull ( "actualException" , actualException ) ; if ( expectedExceptions == null || expectedExceptions . size ( ) == 0 ) { // All exceptions are expected return true ; } final Throwable cause = actualException . getCause ( ) ; if ( ! ( cause instanceof Exception ) ) { // We're only interested in exceptions return false ; } return expectedException ( ( Exception ) cause , expectedExceptions ) ; }
Verifies if the cause of an exception is of a given type .