docs: private final static void printStackTrace(Throwable t, PrintWriter p) {
          if (t == null) {
              p.println("none");
              return;
          }
  
          // Capture any exceptions while printing stack so we return what we have
          // so far
          try {
              // Print the stack trace of the Throwable.
              t.printStackTrace(p);
          } catch (Throwable e) {
              // Do not throw exception, add a message to PrintWriter and return
              // what we have so far.
              p.println("<Encountered exception while printing stack trace>");
              p.println(e.getClass().getName() + ": " + e.getMessage());
              return;
          }
  
          // Handle the degenerate case of a TraceException which contains an
          // array of Throwables.
  //        if (t instanceof TraceException) {
  //            TraceException te = (TraceException) t;
  //            Throwable subexs[] = te.getSubexceptions();
  //            if (subexs == null)
  //                return;
  //            for (int i = 0; i < subexs.length; i++) {
  //                p.println("----- Begin backtrace for subexception[" + i + "]");
  //                printStackTrace(subexs[i], p);
  //            }
  //            return;
  //        }
  
          // Normal Throwables may contain a single nested Throwable. So this
          // Throwable could be the
          // start of a chain of Throwables. We want to obtain the stack traces of
          // all Throwables in
          // the chain so we can see the entire history, execution path and root
          // exception.
          // Some Throwables that support nesting provide support for
          // automatically walking the chain
          // by providing the appropriate printStackTrace() overrides. Others do
          // not, which means we
          // need to manually walk the chain if we want to obtain all the stack
          // traces.
          // If printStackTrace is called on a Throwable chain that contains
          // Throwables that have
          // overriden printStackTrace, the recursion will end after printing out
          // the stack trace of
          // the first Throwable that does not provide an override. If
          // printStackTrace is called on
          // a chain where the base Throwable does not provide the override, then
          // only the stack trace
          // of the base Throwable will have been printed. Therefore, to obtain
          // the next Throwable that
          // needs its stack trace printed, simply walk the chain starting at the
          // base, find the first
          // Throwable that does not provide an override, then start with that
          // guys nested Throwable.
  
          // updated to support J2SE1.4's nested Throwables.
  
          boolean autoRecursion = true;
          Throwable tNext = null;
  
          // Capture any exceptions while calculating nexted exception so we return what we have
          // so far
          try {
              // Compute tNext - the first Throwable in the stack that doesn't recurse
              // properly
              while (autoRecursion) {
  
                  // all known throwables printStackTrace methods recurse properly
                  // when cause is set.
                  tNext = t.getCause();
                  if (tNext != null) {
                      t = tNext;
                  } else {
                      tNext = getNestedThrowable(t);
                      if (tNext == null) {
                          // no cause or nested Throwable - done
                          return;
                      }
  
                      // some of the known throwables with custom nesting don't
                      // recurse properly
                      if (pstRecursesOnNested(t)) {
                          t = tNext;
                      } else {
                          autoRecursion = false;
                      }
                  }
  
              }
          } catch (Throwable e) {
              // Do not throw exception, add a message to PrintWriter and return
              // what we have so far.
              p.println("<Encountered exception while calculating a nested throwable>");
              p.println(e.getClass().getName() + ": " + e.getMessage());
              try {
                  // Try to convert that exception into a stack trace.
                  e.printStackTrace(p);
              } catch (Throwable e2) {
                  p.println("<Caught exception while printing stack trace from failed nested calculation>");
                  p.println(e2.getClass().getName() + ": " + e2.getMessage());
              }
              return;
          }
  
          // tNext will not be null at this point
  
          // Have found the first Throwable that doesn't include nested throwable
          // in printStackTrace
          // Obtain the nested Throwable and keep going.
          p.println("---- Begin backtrace for Nested Throwables");
          printStackTrace(tNext, p);
  
          /*
           * while (pstRecurses(t)) { t = getNestedThrowable(t); if (t == null)
           * return; }
           *
           * // Have found the first Throwable that doesn't override
           * printStackTrace. // Obtain the nested Throwable and keep going. t =
           * getNestedThrowable(t); if (t == null) return;
           * p.println("---- Begin backtrace for Nested Throwables");
           * printStackTrace(t, p);
           */
      }