User`s guide
Programming with VISA 3
Agilent VISA User’s Guide 83
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.
3 Code in any operation (after calling an exception handler)
may not be called if the handler does not return. For
example, local allocations must be freed before invoking
the exception handler, rather than after it.
One situation in which an exception event will not be
generated is in the case of asynchronous operations. If the
error is detected after the operation is posted (i.e., once the
asynchronous portion has begun), the status is returned
normally via the I/O completion event.
However, if an error occurs before the asynchronous portion
begins (i.e., the error is returned from the asynchronous
operation itself), then the exception event will still be raised.
This deviation is due to the fact that asynchronous
operations already raise an event when they complete, and
this I/O completion event may occur in the context of a
separate thread previously unknown to the application. In
summary, a single application event handler can easily
handle error conditions arising from both exception events
and failed asynchronous operations.