LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

20 custom errors-how to code this?

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?

0 Kudos
Message 1 of 10
(4,410 Views)

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?

0 Kudos
Message 2 of 10
(4,398 Views)

@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".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 10
(4,385 Views)

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.

Spoiler
FireFist-Redhawk_0-1624553815517.png

 

Redhawk
Test Engineer at Moog Inc.

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.

Message 4 of 10
(4,378 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 10
(4,375 Views)

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." 😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 10
(4,372 Views)

@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.

 

altenbach_0-1624555534590.png

 

0 Kudos
Message 7 of 10
(4,341 Views)

I would avoid redefining existing error codes if at all possible.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 10
(4,320 Views)

@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.

 

altenbach_0-1624555534590.png

 


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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(4,288 Views)

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.

er1.pnger2.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 10 of 10
(4,284 Views)