JavaScript – Get Stack Trace as String


public static String getStackTrace(Throwable e){
    StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    String stacktrace = sw.toString();
    return stacktrace;
}