Java Stacktrace stackTrace2String(Throwable e)

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

Description

make exception stack trace become string

License

Apache License

Parameter

Parameter Description
e a parameter

Declaration

public static String stackTrace2String(Throwable e) 

Method Source Code

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

public class Main {
    /**/*w  w  w .j  a  va  2 s. c  o m*/
     * make exception stack trace become string
     *
     * @param e
     * @return
     */
    public static String stackTrace2String(Throwable e) {
        StringBuffer sb = new StringBuffer();
        sb.append(e.toString()).append("\r\n");
        StackTraceElement[] traces = e.getStackTrace();
        for (StackTraceElement trace : traces) {
            sb.append(trace.toString()).append("\r\n");
        }
        return sb.toString();
    }
}

Related

  1. stacktrace()
  2. stackTrace(final Exception t)
  3. stackTrace(final Throwable caught)
  4. stackTrace(int depth)
  5. stackTrace(StackTraceElement[] stackTrace)
  6. stackTraceApproved(StackTraceElement elt, String[] approved)
  7. stackTraceAsString(Throwable t)
  8. stackTraceContainsCause(Throwable throwable, Class searchedCause)
  9. stackTraceElementToString( StackTraceElement element)