code: protected static String getStackTrace(final Throwable cause) {
      if (cause == null) {
        return null;
      } else {
        final StringWriter writer = new StringWriter();
        cause.printStackTrace(new PrintWriter(writer));
        return writer.toString();
      }
    }
docs: Helper function: produce the string that contains the given exception's stack trace.
  Returns null if the argument is null.
  
  @param cause Java Exception or null.
  @return A string that contains the exception stack trace, or null.