How to handle errors when calling the onvif client library API?

Let's call onvif_GetDeviceInformation as an example:

// Define an ONVIF_DEVICE variable
ONVIF_DEVICE g_device;

// open log file
log_init("log.txt");
log_set_level(LOG_DBG);

// init system buffer
sys_buf_init(10 * MAX_DEV_NUMS);

// init http message buffer
http_msg_buf_init(10 * MAX_DEV_NUMS);

// init g_device
memset(&g_device, 0, sizeof(g_device));

g_device.binfo.XAddr.https = 0; // If using an HTTPS connection, set it to 1
g_device.binfo.XAddr.port = 8000; // Specify the ONVIF service port of the device
strcpy(g_device.binfo.XAddr.host, "192.168.1.3"); // Specify the IP address of the device
strcpy(g_device.binfo.XAddr.url, "/onvif/device_service");

// set device login information
onvif_SetAuthInfo(&g_device, "admin", "admin");

// Next you can call other API interfaces.

if (!GetSystemDateAndTime(&g_device))
{
    printf("%s, GetSystemDateAndTime failed\r\n", g_device.binfo.XAddr.host);
}

if (!GetCapabilities(&g_device))
{
    printf("%s, GetCapabilities failed\r\n", g_device.binfo.XAddr.host);
}

if (!GetServices(&g_device))
{
    printf("%s, GetServices failed\r\n", g_device.binfo.XAddr.host);
}

if (!GetDeviceInformation(&g_device))
{
    printf("%s, GetDeviceInformation failed\r\n", g_device.binfo.XAddr.host);

    if (g_device.authFailed) // Authentication failed
    {
        printf("Authentication failed\r\n");
    }

    switch (g_device.errCode)
    {
    case ONVIF_ERR_ConnFailure: // Connection failed
        break;
    case ONVIF_ERR_MallocFailure: // Failed to allocate memory
        break;
    case ONVIF_ERR_NotSupportHttps: // The device requires an HTTPS connection, but the onvif client library does not support it (the HTTPS compilation macro is not enabled)
        break;
    case ONVIF_ERR_RecvTimeout: // Message receiving timeout
        break;
    case ONVIF_ERR_InvalidContentType: // Device response message content is invalid
        break;
    case ONVIF_ERR_NullContent: // Device response message has no content
        break;
    case ONVIF_ERR_ParseFailed: // Parsing the message failed
        break;
    case ONVIF_ERR_HandleFailed: // Message handling failed
        break;
    case ONVIF_ERR_HttpResponseError: // The device responded with an error message
        printf("Code=%s\r\n", g_device.fault.Code);
        printf("Subcode=%s\r\n", g_device.fault.Subcode);
        printf("Reason=%s\r\n", g_device.fault.Reason);
        break;
    }
}