code: public static Throwable rootCause(Throwable e) {
          Throwable cause = e;
          while (cause.getCause() != null) {
              cause = e.getCause();
          }
          return cause;
      }
docs: Gets the root cause of an exception.
  @param e the root cause
  @return the throwable