Defining Custom Error Codes Using the General Error Handler VI

Complete the following steps to define custom error codes using the General Error Handler VI.

  1. Add the General Error Handler VI to the block diagram.

     Add  Find
  2. Right-click the [user-defined codes] input and select Create»Constant from the shortcut menu. An array appears.
  3. Double-click the numeric constant and enter a number within the range of -8999 to -8000, 5000 to 9999, or 500,000 to 599,999 in the array. For example, enter 5008.
  4. Right-click the [user-defined descriptions] input and select Create»Constant from the shortcut menu. Another array appears.
  5. Double-click the string constant and enter a description in the user-defined description array. For example, enter Ignore this message.
  6. Right-click the error in input and select Create»Constant from the shortcut menu. A cluster appears that contains a Boolean constant, a numeric constant, and an array.
  7. Use the Operating tool to set the Boolean control to TRUE.
  8. Double-click the numeric constant and enter the same number that appears in the [user-defined codes] constant.
Note  As an alternative to steps 6 through 8, you can wire a numeric constant with the specified error code to the Error Cluster From Error Code VI. Then wire the error out output of the Error Cluster From Error Code VI to the error in input of the General Error Handler VI.
  1. Run the VI. An error dialog appears and displays the customized error code and description. Click the Continue button in this error dialog.
  2. Double-click the General Error Handler subVI and view the front panel. Switch to the VI in which you defined your custom error code, and run the VI again. Click the Continue button again and notice that the message text box on the front panel of the General Error Handler VI displays the same customized error code and description as the error dialog.

You also can define custom error codes by creating an XML-based text file and adding the error codes and messages to the text file.