GW2FileErrorMsg
Hàm GW2FileErrorMsg truy xuất thông báo lỗi do Glasswall báo cáo cho một session ID nhất định. Thông báo lỗi được đặt trong một bộ đệm đầu ra.
Nếu có nhiều hơn một lý do gây ra lỗi, chỉ một lý do sẽ được báo cáo bởi lệnh gọi hàm này. Nếu cần chi tiết về lỗi, chúng sẽ có trong báo cáo phân tích được tạo ra nếu một trong hai hàm GW2RegisterAnalysisFile hoặc GW2AnalysisRegisterMemory đã được gọi trên phiên. Nếu không, tài liệu có thể được Glasswall xử lý bằng một trong hai hàm đó trong một phiên khác để tạo báo cáo phân tích chi tiết.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
#include "glasswall.core2.api.h"
// The **GW2FileErrorMsg** function retrieves the error message reported by Glasswall.
// A pointer to the error message is placed in the object pointed to by **errorMsgBuffer**
// and the size, in bytes, of the error message is placed in the **size_t** object
// pointed to by **errorMsgBufferLength**.
int GW2FileErrorMsg(
Session session,
char **errorMsgBuffer,
size_t *errorMsgBufferLength);
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Tóm tắt
/// <summary>
///
/// </summary>
/// <param name="session">Session ID number</param>
/// <param name="outputBuffer">Location in memory where the error message will be placed</param>
/// <param name="bufferLength">Size of the output buffer</param>
public int FileErrorMsg(
int session,
out IntPtr outputBuffer,
ref UIntPtr bufferLength)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Tóm tắt
import com.glasswall.core2javabridge.*;
public String GW2FileErrorMsgString(int session) throws GlasswallException
Lưu ý
Các tham số của hàm GW2FileErrorMsgString đã được cập nhật để sử dụng String thay cho byte[], đồng thời loại bỏ nhu cầu phải gọi GetErrorBuffer để truy xuất dữ liệu. Các hàm gốc đã bị ngừng dùng.
Giá trị trả về
GW2FileErrorMsgString trả về một String chứa các thông báo lỗi của phiên. String sẽ trống nếu không có thông báo lỗi nào để truy xuất.
Một ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ hoặc nếu không thể truy xuất thông báo lỗi.
Tóm tắt - Các hàm không còn được dùng
import com.glasswall.core2javabridge.*;
(Deprecated)
public int GW2FileErrorMsg(int session) throws GlasswallException
public byte[] GetErrorBuffer(int session) throws GlasswallException
Mô tả
Hàm GW2FileErrorMsg xuất thông báo lỗi tệp cho phiên được chỉ định bởi session vào một bộ đệm nội bộ. Hãy gọi GetErrorBuffer sau khi gọi GW2RunSession để truy xuất dữ liệu thông báo lỗi.
Tham khảo API Overview/Return types để biết các giá trị liệt kê hợp lệ cho format.
Giá trị trả về - Các hàm không còn được dùng
Hàm GW2FileErrorMsg trả về một giá trị liệt kê GW2_RetStatus được chuyển đổi thành int. Giá trị sẽ là số âm nếu xảy ra lỗi. 0 cho biết thành công. Tham khảo API Overview/Return types để biết chi tiết.
Hàm GetErrorBuffer trả về một mảng byte chứa chi tiết lỗi. Giá trị này sẽ là null nếu GW2FileErrorMsg chưa được gọi.
Một ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ hoặc nếu không thể truy xuất thông báo lỗi.
Tóm tắt
Truy xuất thông báo lỗi của Glasswall Session Process.
def file_error_message(self, session: int) -> str:
""" Retrieve the Glasswall Session Process error message.
Args:
session (int): The session integer.
Returns:
error_message (str): The Glasswall Session Process error message.
"""
Giá trị trả về
Một thông báo lỗi dưới dạng chuỗi.
Tóm tắt
/**
* This function retrieves the error message reported by Glasswall. If more than one error
* is reported, the last one will be returned.
*
*/
GW2FileErrorMsg(
session,
errorMsgBuffer,
errorMsgBufferLength)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Ví dụ
function getFileErrorMsg(session_id, gw) {
/*
GW2FileErrorMsg API signature
int GW2FileErrorMsg(
Session session,
char **errorMsgBuffer,
size_t *errorMsgBufferLength
);
*/
// allocate pointer space to store the pointer to the message buffer
let CString_ptr = ref.refType(ref.types.CString);
let errorMsgBuffer = ref.alloc(CString_ptr);
// allocate space to store the buffer length; use .deref() to extract it
let errorMsgBufferLength = ref.alloc('size_t');
let rv = gw.GW2FileErrorMsg(session_id, errorMsgBuffer, errorMsgBufferLength);
buf_len = errorMsgBufferLength.deref();
if (buf_len == 0)
arr_buf = "";
else
arr_buf = buffer_to_array(errorMsgBuffer, errorMsgBufferLength);
let message = `\n GW2FileErrorMsg:return=${rv}`;
message += "\n errorMsgBuffer = \"" + arr_buf.toString() + '"';
message += `\n errorMsgBufferLength = ${buf_len}`;
return message;
}