User`s guide
84 Agilent VISA User’s Guide
3 Programming with VISA
Using the VI_EVENT_EXCEPTION Event
You can use the VI_EVENT_EXCEPTION event as notification
that an error condition has occurred during an operation
invocation. The following table describes the
VI_EVENT_EXCEPTION event attributes.
Sample: Exception Events
/* This is an example of how to use exception
events to trap VISA errors. An exception event
handler must be installed and exception events
enabled on all sessions where the exception
handler is used.*/
#include <stdio.h>
#include <visa.h>
ViStatus __stdcall myExceptionHandler (
ViSession vi,
ViEventType eventType,
ViEvent context,
ViAddr usrHandle
) {
ViStatus exceptionErrNbr;
char nameBuffer[256];
ViString functionName = nameBuffer;
char errStrBuffer[256];
/* Get the error value from the exception
context */
viGetAttribute( context, VI_ATTR_STATUS,
&exceptionErrNbr );
Table 24 VI_EVENT_EXCEPTION Event Attributes.
Attribute Name Access Privilege Data Type Range Default
VI_ATTR_EVENT_TYPE RO Global ViEventType VI_EVENT_EXCEPTION N/A
VI_ATTR_STATUS RO Global ViStatus N/A N/A
VI_ATTR_OPER_NAME RO Global ViString N/A N/A