code: public static String toStackTraceString(String firstLine, StackTraceElement[] stack)
    {
      //add the class name and any message passed to constructor
      final StringBuilder result = new StringBuilder(firstLine);
      //result.append(aThrowable.toString());
      final String NEW_LINE = System.getProperty("line.separator");
      result.append(NEW_LINE);
  
      //add each element of the stack trace
      for (StackTraceElement element : stack ){
        result.append("  at ");
        result.append( element );
        result.append( NEW_LINE );
      }
      return result.toString();
    }
docs: Defines a custom format for the stack trace as String.