06-01-2011 09:20 AM
In the attached vi, I tried to edit the error message that is generated by LabVIEW. But instead, my text is added to the list of Possible Reason(s) displayed in the error message. Can I programmatically change an error message that is generated by LabVIEW?
06-01-2011 09:26 AM - edited 06-01-2011 09:29 AM
The easiest way would simply be to replace the error cluster with the value you want. In addition you can use the Bundle by Name cluster primative to replace the error string with your own message. Wire the error into the input
06-01-2011 09:30 AM
It can be done like this
06-01-2011 12:05 PM
Thanks, but I'm concerned about modifying the error description that appears in the error message generated from the General Error Handler.
06-01-2011 12:08 PM
The example that I gave you only changes the error code for the one error that is identified in the case otherwise it passes the orginal error information.
06-01-2011 12:14 PM - edited 06-01-2011 12:16 PM
@Vi Joe wrote:
Thanks, but I'm concerned about modifying the error description that appears in the error message generated from the General Error Handler.
I think I understand- Try the topic on
The following ranges of error codes are reserved for you to define custom error messages:
Complete the following steps to define custom error codes.
Note As an alternative to steps 6 through 8, you can wire a numeric constant with a value of 5008 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. |
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.
And
National Instruments recommends that you use the General Error Handler VI to define custom error codes in the range of -8999 through -8000, 5000 through 9999, or 500,000 through 599,999. However, you also can define custom error codes in the same range using the Error Code File Editor dialog box. Use this method if you want to use the same custom error codes with several VIs or if you want to distribute custom error codes with an application or shared library. If you want to distribute the custom error codes with an application or shared library, you must distribute the error code text files.
Complete the following steps to define custom error codes using the Error Code File Editor.
You also can define custom error codes in the same range by creating an XML-based text file. You must name the text file xxx-errors.txt, where xxx is a name that you supply. The xxx-errors.txt file must use the following syntax exactly, including capitalization, spacing, and so on. You supply the italic text:
<?xml version="1.0"?>
<nidocument>
<nicomment>
This file describes custom errors for my VI.
</nicomment>
<nierror code="5000">
Memory full.
Add more memory.
</nierror>
<nierror code="5001">
Invalid name. Enter a new name.
</nierror>
</nidocument>
You can add your own comment between the <nicomment></nicomment> tags. In each <nierror> tag, you must define the error code number. Define the error code message between the <nierror></nierror> tags.
Changes to error code text files take effect the next time you start LabVIEW.
06-01-2011 12:17 PM
@Vi Joe wrote:
Thanks, but I'm concerned about modifying the error description that appears in the error message generated from the General Error Handler.
No only that you are not permanently changing the error message. You are only changing it when you us it in this vi for this instance that it is called. You are not changing it in LabVIEW permanently.
06-01-2011 12:23 PM
I strongly advise against placing your own error description in the "source" field of the error cluster. As the name implies, this field should only contain the call chain indicating where an error happened. If you want to create your own error code and description, you should do so by creating an error code file (Tools >> Advanced >> Edit Error Codes...). You can then generate an error with Error Cluster From Error Code.vi with your custom error code wired in.
Chris M
06-01-2011 02:16 PM
Thanks to everyone's help, I think the attached vi meets my needs - unless someone has a better idea.
06-01-2011 02:20 PM
You do not need the outer case structure around the code. It is just extra.