code: public static String getStackTraceString(Throwable throwable) {
          StringWriter sw = null;
          PrintWriter pw = null;
          try {
              sw = new StringWriter();
              pw = new PrintWriter(sw);
              pw.println(throwable.toString());
              throwable.printStackTrace(pw);
              pw.flush();
              return sw.toString();
          } finally {
              closeQuietly(pw);
              closeQuietly(sw);
          }
      }
docs: Converts stack trace to string.
  
  @param throwable - throwable to convert.
  @return message and stack trace converted to string.