Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java exception to string

public static String readStackTrace(Throwable exception) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);

        try {
            exception.printStackTrace(printWriter);
        } catch (Throwable var6) {
            try {
                printWriter.close();
            } catch (Throwable var5) {
                var6.addSuppressed(var5);
            }

            throw var6;
        }

        printWriter.close();
        return stringWriter.toString();
    }
 
PREVIOUS NEXT
Tagged: #java #exception #string
ADD COMMENT
Topic
Name
3+5 =