06-24-2021 11:20 AM - edited 06-24-2021 11:25 AM
I have about 20 error messages I need to code. I have an array element output that will indicate a number 0-20
A 0 is no error, but any other number (1-20) would indicate one of the custom errors mentioned above. How do I code this? I tried an error ring but it looks like I can only add one custom error, is an error cluster better, or is there something else?
06-24-2021 11:41 AM
What is an "error ring"?
Basically, you have a numeric code (0..20) and for each maybe a string, describing the error? What else?
You cannot use regular error datatype, because most codes 0..20 are already taken.
You can create an enum where the value is the error code and the string is the description.
You can use an array of string where you use the code to index into it to get the error message.
You can do many other things to solve the problem!
Can you explain how you are planning to use all this? Maybe some sample code? Are the error assignments fixed at compile time or not? Do you need to support different languages?
06-24-2021 11:52 AM
@altenbach wrote:
What is an "error ring"?
Look in the Dialog & User Interface dialog. The Error Ring is a great thing to know how to use.
Now to the OP: What issue are you having with the Error Ring? How are you generating these errors? I typically just have Error Rings in case statements for things like "Item Not Found".
06-24-2021 11:57 AM
Easiest way in my mind would be to make a SubVI that takes an error cluster and the array element as inputs, and insert an error based on the array element and output it, like so... This would mean making 20 error rings but you'd only have to do it once. Could also skip the error in and do the merge error outside the SubVI and only if you need to.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
06-24-2021 11:58 AM
Go to Tools->Advanced->Edit Error Codes. This allows you to create custom errors codes that can be handled with the general error handler. Your errors codes should be between -8999 to -8000, 5000 to 9999 or 500000 to 599999. You can get more information here.
06-24-2021 11:59 AM - edited 06-24-2021 12:01 PM
Also, are the error numbers a requirement, or can you translate them into one of the custom LV error ranges (–8999 through –8000, 5000 through 9999, or 500,000 through 599,999)? e.g., -8001... -8020 (0 is already LabVIEW "no error", and I am assuming that if the error code returned is "0" you report nothing to the customer - just like LV error 0).
Edit:
Dang, Mark beat me to it. "You snooze, you lose, I guess." 😄
06-24-2021 12:26 PM
@crossrulz wrote:
Look in the Dialog & User Interface dialog. The Error Ring is a great thing to know how to use.
My impression as that he wanted to redefine errors with code 0..20. The error ring has these values already reserved.
06-24-2021 12:58 PM
I would avoid redefining existing error codes if at all possible.
06-24-2021 05:08 PM
@altenbach wrote:
@crossrulz wrote:
Look in the Dialog & User Interface dialog. The Error Ring is a great thing to know how to use.
My impression as that he wanted to redefine errors with code 0..20. The error ring has these values already reserved.
That's why I suggested transposing them to one of the user-reserved error code ranges (unless it is a customer requirement that they be 1-20).
Error rings are nice because you can insert data into your error text via parameters. You don't get the "undefined" error, either. I think the error ring is self-contained. If you change a standard LV error, the modification only lives in the ring.
06-24-2021 05:33 PM
Although each instance of an error ring can be for only one error code, you can include string formatting specs in the error description and that will add inputs to the Error Ring.