Example Code

Programmatically Generate Custom Error Codes/Messages

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

Download All

Overview

This demonstrates using the General Error Handler VI to report your own custom errors.

 

 

Description

This examples shows how to use the general error handler to programmatically generate custom error messages. In the course of an application it may be necessary to generate an error even though nothing has caused LabVIEW to generate an error. For example, if you are performing a file I/O task and LabVIEW generates error code 4, an error has occurred where the "End of file encountered." However, if you want to report an error even though nothing has gone wrong as far as LabVIEW is concerned, using the general error handler allows you to generate custom error codes.

 

An example of a situation where this might apply:

Your program is used to run a motor. When motors run, they generate heat; so in your program you are also monitoring this temperature. In the rare situation where your motor overheats, you want to generate an error, turn off the motor, and end your program. So, even though the temperature of your motor being too hot would not cause LabVIEW to report an error, you need LabVIEW to report that the motor has overheated and close down in a controlled fashion.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code

1. Download and Open "Generate Custom Errors_LV2012_NI Verified.vi"

2. Run the VI

3. Trip error 5003 or 5004 with one of the switches.

4. Notice how LabVIEW reports the error as if it was built-in

 

 

Additional Information or References

Block Diagram

bd.PNG

 

 

 

 

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

Hope this helps.
-Ben

WaterlooLabs

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