# swiGetLastError

Retrieves the last MVIP device error on the switch handle
.

#### Prototype

DWORD swiGetLastError ( SWIHD swihd, DWORD *errorcode)

Argument | Description
swihd | Switch handle.
errorcode | Pointer to the code of the device error.

#### Return values

Return value | Description
SUCCESS |
CTAERR_INVALID_HANDLE | swihd is not a valid switch handle.
CTAERR_SVR_COMM | Communication error in the server environment.

#### Details

Call swiGetLastError if a Switching service function returned CTAERR_DRIVER_ERROR. swiGetLastError retrieves the last error returned by the switching device driver on the specified switch handle.

For a description of the error codes, refer to the MVIP-95 Device Driver Standard Manual.

#### Example

void myErrorHandler(SWIHD hd, char *text, DWORD status)
{
DWORD errorcode, ret;
fprintf(stderr, "Error (%d): %s", status, text);
ret = swiGetLastError(hd, &errorcode);
if (ret == SUCCESS)
fprintf(stderr, "** MVIP driver error code: %d\n", errorcode);
}