Custom Error Code
Custom Error Codes are set aside for use when an existing error code does not adequately describe the error condition. The developer can define custom error codes that are specific to the application. They do not need to conform to any other application.
Custom Error Code Ranges
Custom error codes can range from:
- -8999 through -8000
- 5000 through 9999
- 500,000 through 599,999.
Even though these codes are available to define custom errors, it is more important to provide a good explanation of the error and how to fix it rather than having unique error codes for every error. However, if the developer will use the error code to direct the response, display, or logging differently for different errors, than the error code could be necessary. It is often useful to define code bands during the project planning stage, setting aside bands for specific related error groups and/or error handling.
Custom Error Definition XML
Although General Error Handler.vi can be used to define custom error codes, one can also create an XML file in the labview\user.lib\errors directory that contains custom error codes and their descriptions. This method is particularly useful if the user requires custom error codes to apply to several applications, or if the codes are used by several software engineers in a team or are to be distributed with an application.
For example, the XML filename must be in the format *-errors.txt (where * is user definable), and the internal file structure must adhere to the following format:
This is a custom error code definition file for my application.
User Access Denied!
Contact the Security Department to gain clearance to perform this function.
Contact the People Development Department.
Driver Unable to Contact Instrument Database.
Contact the Software Engineering Department Helpdesk.
Plug-In Module in R&D mode – not to be used in Production Environment.
Contact the New Product Development Group.
As can be seen, a file comment can be created within the <nicomment> tag space. Each custom error is defined as an <nierror> with it’s associated error code, and its error message is then placed inside the <nierror> tag space. Although hand coding a custom error code XML file is possible, the Error Code File Editor (Tools->Advanced->Edit Error Codes) provides a simple GUI for file creation and editing.
Once custom error code files have been created and/or altered, LabVIEW must be restarted for the changes to take effect.