public static Throwable unwrap ( Throwable t ) { for ( ; ; ) { if ( t == null ) throw new NullPointerException ( ) ; if ( t instanceof java . util . concurrent . ExecutionException ) t = t . getCause ( ) ; else if ( t instanceof java . lang . reflect . InvocationTargetException ) t = t . getCause ( ) ; else if ( t . getClass ( ) . equals ( RuntimeException . class ) && t . getCause ( ) != null ) t = t . getCause ( ) ; else return t ; } }
Unwraps several common wrapper exceptions and returns the underlying cause .