Example Code

Error Handling Techniques Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI demonstrates different ways of handling errors in LabVIEW

 

Description

The first method demonstrated manually creates an error cluster. The second method creates an error cluster when only given an error code. The third method is the standard error passing that many VIs implement. Finally, merging multiple errors is demonstrated. This example does not nearly cover all the different ways to handle errors.  If you have other ideas that would be helpful, feel free to edit the VI and the VI Snippet and add them to this document.

  

Requirements

LabVIEW 2012 or compatible

  

Steps to Implement or Execute Code

  1. Take the error out of a VI and use a Case Structure to determine if you want to manually create an error. If so, use a Bundle by Name function and enter the values for the status, code and source.
  2. If a DLL returns an error code- in order to create an error cluster from it, use the Error Cluster from Error Code VI. Input the appropriate error message.
  3. Standard VIs will pass out an error cluster
  4. Use Merge Errors to combine multiple error wires into one. Merge Errors will return the first error found. If there are no errors, it will return the first warning found. If there are no warnings, no error is returned.

Additional Information or References

VI Block DiagramError Handling Techniques LV2012 NI Verified BD.png

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.