Java Throwable to String getStackTrace(@Nonnull final Throwable throwable)

Here you can find the source of getStackTrace(@Nonnull final Throwable throwable)

Description

Yoinked from apache commons 3 because that's what we were using.

License

Open Source License

Declaration

@Nonnull
@Deprecated
private static String getStackTrace(@Nonnull final Throwable throwable) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.annotation.Nonnull;
import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /**//from   w  w w .j a va2 s .c  o  m
     * Yoinked from apache commons 3 because that's what we were using.
     * Keeping this method because of backward compatibility reasons.
     * We don't want commons-lang-3 as a dependency though.
     *
     * @deprecated figure out how to stop using this.
     */
    @Nonnull
    @Deprecated
    private static String getStackTrace(@Nonnull final Throwable throwable) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        throwable.printStackTrace(pw);
        return sw.getBuffer().toString();
    }
}

Related

  1. getExceptionString(Throwable t)
  2. getExceptionString(Throwable throwable)
  3. getExceptionText(Throwable e)
  4. getExceptionTrace(Throwable e)
  5. getStackTrace (final Throwable e)
  6. getStackTrace(final Throwable aThrowable)
  7. getStackTrace(final Throwable e)
  8. getStackTrace(final Throwable error)
  9. getStackTrace(final Throwable exception)