Device Function

Get Last Error


Retrieve the last LayGO error code.

#include "device.h"

LResult  dev_GetLastError
         LDevice        device,
         LProtocol *    protocol
devicedevice to query
protocoloutput for id of protocol which returned the error

When a device function fails because of failure of a LayGO API function, the LayGO error code is stored internally, along with the identity of the layer which gave the error. dev_GetLastError() returns the last LayGO error code and protocol id. The protocol id is available only if the device has been successfully opened.

Return Values

If successful, dev_GetLastError() returns a negative value in the range of LayGO error codes. If the last device function did not fail because of failure of a LayGO function, zero is returned. Otherwise, it returns a negative value in the range of device error codes indicating the reason it failed. Possible unsuccessful return values are:

See Also


if ((result = dev_Open(device)) < 0)
    if (result == dev_ERROR_SERVICE_OPEN_FAILURE)
        LOG("Open failure",
            lgo_ErrorMessage(dev_GetLastError(device, NULL)));