![background image](http://html1.mh-extra.com/html/national-instruments/bridgeview/bridgeview_user-manual_3445534318.webp)
Chapter 16
Program Design
16-6
©
National Instruments Corporation
The BridgeVIEW Engine handles system events and errors reported by
device servers. However, your VIs must handle any error conditions within
their diagrams. For example, if a VI is unable to open a file properly, you
might want the VI to halt or inform the user of the error through a dialog
box. You also might want the VI to use an alternative path before alerting
the user of the error. You can make these error-handling decisions in the
block diagram of your VI.
The following list describes situations in which errors frequently occur:
•
Incorrect initialization of communication or data that has been written
to an external device improperly
•
Loss of power in an external device, or a broken or improperly working
external device
•
Change in functionality of an application or library when upgrading
operating system software
When an error occurs, you might not want certain subsequent operations to
occur. For instance, if an analog output operation fails because you specify
the wrong device, you might not want a subsequent analog input operation
to take place.
One method for managing such a problem is to test for errors after every
function and place subsequent functions inside case structures. However,
this method can complicate your diagrams and ultimately hide the purpose
of your application.
An alternative approach, which has been used successfully in a number of
applications and many of the VI libraries, is to incorporate error handling
in the subVIs that perform I/O. Each VI can have an error input and an error
output. You can design the VI to check the error input to see if an error has
occurred previously. If an error exists, you can configure the VI to do
nothing and pass the error input to the error output. If no error exists, the VI
can execute the operation and pass the result to the error output.
Note
In some cases, such as a Close operation, you might want the VI to perform the
operation regardless of the error that is passed into it.
Using the preceding technique, you can wire several VIs together,
connecting error inputs and outputs to propagate errors from one VI to the
next. At the end of the series of VIs, you can use the Simple Error Handler
VI to display a dialog box if an error occurs. The Simple Error Handler VI
is located in Functions»Time & Dialog. In addition to encapsulating error
handling, you can use this technique to determine the order of several
I/O operations.