Occasionally, it can be desirable to clear a specific error when we run our VI. The code below will clear a specific error using Clear Specific Error.vi, and is adaptable to be used as a subVI within a larger application.
First we use the Error Cluster from Error Code.vi to create two different error clusters, -20 and -20315. (The errors chosen are arbitrary and do not match any of those in the General LabVIEW Error Code list.) Depending on which position the rocker switch is in, the case structure passes one of these errors through for us to check whether the error code matches the error we are looking to clear, whose value is selected on the front panel. We also check that the status of the error is true, in case there is no error or a warning. If the error satisfies both of these conditions, the error is cleared using Clear Errors.vi within a case structure.
If however the error is not cleared, it is then shown on the Error out Indicator and a description of the error is displayed in a dialog box by Simple Error Handler.
LabVIEW 2012 (or compatible)
Steps to Implement or Execute code
1. Using the rocker switch, select which error you want to simulate.
2. Run the VI.
3. If the error you are simulating matches 'Error to clear', notice that no error is reported and that 'error out' reports no error.
4. If the error you are simulating does not match 'Error to clear', notice that the Simple Error Handler displays a dialog box and that the 'Error out' indicator shows an error.
5. You can adjust 'error to clear' by changing the value on the Front Panel.
Additional information or References
If you were using this as a subVI within your code, you would replace Sections 1 and 2 with an error control and wire the connector pane terminals to allow you to pass your errors in. It would also be best practice to remove the Simple Error Handler in this case and instead to use it in your Main VI.
Front Panel of the VI
Block Diagram of the VI
**This document has been updated to meet the current required format for the NI Code Exchange.**