public static < E extends Exception > void throwIfInstance ( Throwable t , Class < E > excClass ) throws E { if ( excClass . isAssignableFrom ( t . getClass ( ) ) ) { // the throwable is already an exception, so return it throw excClass . cast ( t ) ; } }
If the given throwable is an instance of E throw it as an E .