code: public static String printThrowable(Throwable t) {
          if (t == null) {
              return "No Exception details";
          }
          StringBuilder s = new StringBuilder();
          doPrintStackTrace(s, t, null, "", new HashSet<Throwable>());
          return s.toString();
      }
docs: Copied from hudson.Functions, but with external references removed: