niSwitch_GetError

NI-SWITCH Functions

niSwitch_GetError

Specific Function

C Function Prototype

ViStatus niSwitch_GetError (ViSession vi, ViStatus* code, ViInt32 buffersize, ViChar[] description);

Purpose

This function retrieves and then clears the IVI error information for the session or the current execution thread.

One exception exists: If the bufferSize parameter is 0, the function does not clear the error information. By passing 0 for the buffer size, the caller can ascertain the buffer size required to get the entire error description string and then call the function again with a sufficiently large buffer. If you specify a valid IVI session for the vi parameter, this function retrieves and then clears the error information for the session. If the user passes VI_NULL for the vi parameter, this function retrieves and then clears the error information for the current execution thread. If the vi parameter is an invalid session, the function does nothing and returns an error. Normally, the error information describes the first error that occurred since the user last called niSwitch_GetError or niSwitch_ClearError.

Parameters

Name Type Description
vi ViSession A particular NI-SWITCH session established with niSwitch_InitWithTopology, niSwitch_InitWithOptions, or niSwitch_init and used for all subsequent NI-SWITCH calls.

code ViStatus Returns the error code for the session or execution thread.
If you pass 0 for bufferSize, you can pass VI_NULL for this parameter.

buffersize ViInt32 Pass the number of bytes in the ViChar array you specify for the Description parameter.

If the error description, including the terminating NULL byte, contains more bytes than you indicate in this parameter, the function copies bufferSize–1 bytes into the buffer, places an ASCII NULL byte at the end of the buffer, and returns the buffer size you must pass to get the entire value. For example, if the value is "123456" and bufferSize is 4, the function places "123" into the buffer and returns 7. If you pass a negative number, the function copies the value to the buffer regardless of the number of bytes in the value. If you pass 0, you can pass VI_NULL for the description buffer parameter.

description ViChar[] Returns the error description for the IVI session or execution thread.

If there is no description, the function returns an empty string. The buffer must contain at least as many elements as the value you specify with the bufferSize parameter. If the error description, including the terminating NULL byte, contains more bytes than you indicate with the bufferSize, the function copies bufferSize–1 bytes into the buffer, places an ASCII NULL byte at the end of the buffer, and returns the buffer size you must pass to get the entire value. For example, if the value is "123456" and bufferSize is 4, the function places "123" into the buffer and returns 7. If you pass 0 for the Buffer Size, you can pass VI_NULL for this parameter.