public static <T extends Throwable>T writeStackTraces(T throwable,StreamOutput out) throws IOException {
  StackTraceElement[] stackTrace=throwable.getStackTrace();
  out.writeVInt(stackTrace.length);
  for (  StackTraceElement element : stackTrace) {
    out.writeString(element.getClassName());
    out.writeOptionalString(element.getFileName());
    out.writeString(element.getMethodName());
    out.writeVInt(element.getLineNumber());
  }
  Throwable[] suppressed=throwable.getSuppressed();
  out.writeVInt(suppressed.length);
  for (  Throwable t : suppressed) {
    out.writeThrowable(t);
  }
  return throwable;
}

public static < T extends Throwable > T writeStackTraces ( T throwable , StreamOutput out ) throws IOException { StackTraceElement [ ] stackTrace = throwable . getStackTrace ( ) ; out . writeVInt ( stackTrace . length ) ; for ( StackTraceElement element : stackTrace ) { out . writeString ( element . getClassName ( ) ) ; out . writeOptionalString ( element . getFileName ( ) ) ; out . writeString ( element . getMethodName ( ) ) ; out . writeVInt ( element . getLineNumber ( ) ) ; } Throwable [ ] suppressed = throwable . getSuppressed ( ) ; out . writeVInt ( suppressed . length ) ; for ( Throwable t : suppressed ) { out . writeThrowable ( t ) ; } return throwable ; }
serializes the given exceptions stacktrace elements as well as it ' s suppressed exceptions to the given output stream .
