Example Code

Generating Custom Error Code with Original LabVIEW Error Message 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

Description

Overview
This VI allows the developer to generate a custom error code which incorporates the "Possible Reason(s)" message from the original error code.

 
Description
LabVIEW provides methods for developers to generate a custom error code. Generating custom error codes is a useful feature for providing additional information on errors which the developer may regularly come up in certain situations, for generating errors in situations where LabVIEW would not generate one by default, or for testing sections of code to see how they react to specific error conditions by injecting generated errors.

This code aims to expand on the ability to provide additional information to an existing error code, by creating a new error code which also incorporates the troubleshooting message from the original error code.

This is made possible by using the Error Code Database VI, which is a built-in subVI in LabVIEW used by the General Error Handler.

Creation of the custom error message is done through an Error Ring. Learn how to create a custom error.

 
Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Run the Code
  2. An error will be created as the DAQmx create channel has an invalid Physical Channel input
  3. The Simple Error Handler will generate the custom message which includes the original LabVIEW error information

 

Additional Information or References
VI Block Diagram

 1.png

The pop-up error message dialog

Error Window.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.