Java Throwable to String getExceptionTrace(Throwable e)

Here you can find the source of getExceptionTrace(Throwable e)

Description

Get the stack trace of the exception.

License

Apache License

Parameter

Parameter Description
e The exception instance.

Return

The full stack trace of the exception.

Declaration

public static String getExceptionTrace(Throwable e) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /**//www .j av a2 s .  com
      * Get the stack trace of the exception. 
      * @param e The exception instance.
      * @return The full stack trace of the exception.
      */
    public static String getExceptionTrace(Throwable e) {
        if (e != null) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            return sw.toString();
        }
        return "No Exception";
    }
}

Related

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