获取Exception错误的详细信息(堆栈信息)

直接上方法

/**
     * 获取错误的堆栈信息
     * @param throwable
     * @return
     */
    public String getStackTrace(Throwable throwable){
        StringWriter stringWriter=new StringWriter();
        PrintWriter printWriter=new PrintWriter(stringWriter);

        try {
            throwable.printStackTrace(printWriter);
            return stringWriter.toString();
        }finally {
            printWriter.close();
        }

    }

你可能感兴趣的:(获取Exception错误的详细信息(堆栈信息))