根据exception 异常堆栈信息

public static String getExceptionStackTrace(Throwable ex)
    {
        Writer info = new StringWriter();
        PrintWriter printWriter = new PrintWriter(info);
        ex.printStackTrace(printWriter);

        Throwable cause = ex.getCause();
        while (cause != null)
        {
            cause.printStackTrace(printWriter);
            cause = cause.getCause();
        }
        return info.toString();
    }

你可能感兴趣的:(根据exception 异常堆栈信息)