code: public void printStackTrace(java.io.PrintWriter s) {
  
          if (s == null) {
              s = new java.io.PrintWriter(System.err, true);
          }
  
          try {
              String locInfo = getLocationAsString();
  
              if (null != locInfo) {
                  s.println(locInfo);
              }
  
              super.printStackTrace(s);
          } catch (Throwable e) {}
  
          boolean isJdk14OrHigher = false;
          try {
              Throwable.class.getMethod("getCause", (Class<?>) null);
              isJdk14OrHigher = true;
          } catch (NoSuchMethodException nsme) {
              // do nothing
          }        
  
          // The printStackTrace method of the Throwable class in jdk 1.4 
          // and higher will include the cause when printing the backtrace.
          // The following code is only required when using jdk 1.3 or lower                
          if (!isJdk14OrHigher) {
              Throwable exception = getException();
      
              for (int i = 0; (i < 10) && (null != exception); i++) {
                  s.println("---------");
      
                  try {
                      if (exception instanceof DTMException) {
                          String locInfo =
                              ((DTMException) exception)
                                  .getLocationAsString();
      
                          if (null != locInfo) {
                              s.println(locInfo);
                          }
                      }
      
                      exception.printStackTrace(s);
                  } catch (Throwable e) {
                      s.println("Could not print stack trace...");
                  }
      
                  try {
                      Method meth =
                          ((Object) exception).getClass().getMethod("getException",
                              (Class<?>) null);
      
                      if (null != meth) {
                          Throwable prev = exception;
      
                          exception = (Throwable) meth.invoke(exception, (Class<?>) null);
      
                          if (prev == exception) {
                              break;
                          }
                      } else {
                          exception = null;
                      }
                  } catch (InvocationTargetException ite) {
                      exception = null;
                  } catch (IllegalAccessException iae) {
                      exception = null;
                  } catch (NoSuchMethodException nsme) {
                      exception = null;
                  }
              }
          }
      }
docs: Print the the trace of methods from where the error
  originated.  This will trace all nested exception
  objects, as well as this object.
  @param s The writer where the dump will be sent to.