
70
Agilent VISA User’s Guide
3
Programming with VISA
Exception Handling Model
The exception-handling model follows the event-handling model for
callbacks, and it uses the same operations as those used for general
event handling. For example, an application calls
viInstallHandler
and
viEnableEvent
to enable exception events. The exception event is like
any other event in VISA, except that the queueing and suspended
handler mechanisms are not allowed.
When an error occurs for a session operation, the exception handler is
executed synchronously. That is, the operation that caused the exception
blocks until the exception handler completes its execution. The
exception handler is executed in the context of the same thread that
caused the exception event.
When invoked, the exception handler can check the error condition and
instruct the exception operation to take a specific action. It can instruct
the exception operation to continue normally (by returning
VI_SUCCESS) or to not invoke any additional handlers in the case of
handler nesting (by returning VI_SUCCESS_NCHAIN).
As noted, an exception operation blocks until the exception handler
execution is completed. However, an exception handler sometimes may
prefer to terminate the program prematurely without returning the
control to the operation generating the exception. VISA does not
preclude an application from using a platform-specific or
language-specific exception handling mechanism from within the VISA
exception handler.
For example, the C++ try/catch block can be used in an application in
conjunction with the C++ throw mechanism from within the VISA
exception handler. When using the C++ try/catch/throw or other
exception-handling mechanisms, the control will not return to the VISA
system. This has several important repercussions:
1
If multiple handlers were installed on the exception event, the
handlers that were not invoked prior to the current handler will not be
invoked for the current exception.
2
The exception context will not be deleted by the VISA system when
a C++ exception is used. In this case, the application should delete
the exception context as soon as the application has no more use for
the context, before terminating the session. An application should
use the
viClose
operation to delete the exception context.
Содержание E2094S
Страница 6: ...6 Agilent VISA User s Guide ...
Страница 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Страница 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Страница 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...
Страница 144: ...144 Agilent VISA User s Guide Glossary ...