GW2FileErrorMsg
    • PDF

    GW2FileErrorMsg

    • PDF

    Article Summary

    The GW2FileErrorMsg function retrieves the error message reported by Glasswall for a given session ID. The error message is placed in an output buffer. If there was more than one reason for the error, only one will be reported by this function call. If details are required for the failure, they will be present in the analysis report produced if either of the functions GW2RegisterAnalysisFile or GW2AnalysisRegisterMemory were called on the session. If not, the document can be processed by Glasswall using either of those functions in another session to produce a detailed analysis report.

    Synopsis

    #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);
    

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    Synopsis

    /// <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)
    

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    Synopsis

    import com.glasswall.core2javabridge.*;
    
    public String GW2FileErrorMsgString(int session) throws GlasswallException

    Note:

    The GW2FileErrorMsgString function parameters have been updated to use String in place of byte[], and to remove the need to call GetErrorBuffer to retrieve the data. The original functions have been deprecated.

    Returns

    The GW2FileErrorMsgString returns a String containing the session error messages. The String will be empty if there are no error messages to retrieve.

    A GlasswallException exception will be thrown if session is invalid, or if the error message could not be retrieved.

    Synopsis - Deprecated Functions

    import com.glasswall.core2javabridge.*;
    
    (Deprecated)
    public int GW2FileErrorMsg(int session) throws GlasswallException
    public byte[] GetErrorBuffer(int session) throws GlasswallException

    Description

    The GW2FileErrorMsg function outputs the file error message for the session specified by session to an internal buffer. Call GetErrorBuffer after calling GW2RunSession in order to retrieve the error message data.

    Please refer to API Overview for Return Types and valid enumerators for format.

    Returns - Deprecated Functions

    The GW2FileErrorMsg function returns a GW2_RetStatus enumeration converted to int. The value will be negative if an error occurred. 0 indicates success.

    Please refer to the API Overview for Return Types and their details. 

    The GetErrorBuffer function returns a byte array containing the error details. This will be null if GW2FileErrorMsg has not been called.

    A GlasswallException exception will be thrown if session is invalid, or if the error message could not be retrieved.

    Synopsis

    Retrieve the Glasswall Session Process error message.

    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.
        """

    Returns

    An error message as a string.

    Synopsis

    /**
    * 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)

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    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;
    }

    Was this article helpful?