code: public static String getStackTrace( Throwable throwable ) {
          if (throwable == null) return null;
          final ByteArrayOutputStream bas = new ByteArrayOutputStream();
          final PrintWriter pw = new PrintWriter(bas);
          throwable.printStackTrace(pw);
          pw.close();
          return bas.toString();
      }
docs: Get the stack trace of the supplied exception.
  
  @param throwable the exception for which the stack trace is to be returned
  @return the stack trace, or null if the supplied exception is null