public static Throwable extractRootCause(Throwable t){
  Throwable result=t;
  while (result.getCause() != null) {
    result=result.getCause();
  }
  return result;
}

public static Throwable extractRootCause ( Throwable t ) { Throwable result = t ; while ( result . getCause ( ) != null ) { result = result . getCause ( ) ; } return result ; }
extracts the root cause of the exception , no matter how nested it is
