LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you create custom error codes?

I would like to be able to define my own errors for an application and I know that it can be done with codes 5000-9999. What I don't know is how to store the definitions of those custom error codes. I could use the "General Error Handler" if I wished to show an error immediatly or if I wanted to put in custom error handling wherever I need to interpret an error or show it to a user, but I would like to be able to handle all custom errors as though they were built in. I have read somewhere about a database that can be edited to do this but all I saw was a hint. If anybody has any idea where I can go for documentation on this or would like to post it directly it would be appriciated.

Thanks!
Naveen
0 Kudos
Message 1 of 11
(4,046 Views)
Hi Naveen

The database is stored in General Error Handler.vi
Try the following:
1) In an otherwise empty VI, wire in your user codes and descriptions to the General Error Handler.
2) Run the VI
3) Open up General Error Handler and set the current values to default.
4) Save and close General Error Handler.vi
Be careful, because this permanently changes the user error database.

Good Luck
0 Kudos
Message 2 of 11
(4,049 Views)
Is there a way that this can be done that doesn't impact other projects and can be ported to other machines easily? Assuming that the codes I use are not used in other projects and there will be no conflicts.

Thanks,
Naveen
0 Kudos
Message 4 of 11
(4,049 Views)
It depends on how you are doing it. If you are calling the General Error Handler VI, you can just include the user values for each call.
If that is too messy for you (or if there are times you can't use the General Error Handler VI), you will have to do what I said earlier. This modifies the VI to include your user defined errors as default. Then transfer this VI to whereever you need it so that you can see the error codes.

Hope this helps
0 Kudos
Message 5 of 11
(4,049 Views)
Hi Naveen

The database is stored in General Error Handler.vi
Try the following:
1) In an otherwise empty VI, wire in your user codes and descriptions to the General Error Handler.
2) Run the VI
3) Open up General Error Handler and set the current values to default.
4) Save and close General Error Handler.vi
Be careful, because this permanently changes the user error database.

Good Luck
0 Kudos
Message 3 of 11
(4,049 Views)
Hi nmalik;

This is what I do. It may not be the ideal solution, but work for me 🙂

I create my own error handler vi around the general error vi. I add two constant arrays defining with the error numbers and descriptions. That's my error database. The first attached vi is an example of a custom error vi.

Also, as you can see, I always identify my errors with negative numbers. That way, for me there is no confusion of from where the error originate. LabVIEW errors are positive.

To create the database I create a little vi helper. That vi read a text file with the errors numbers and descriptions and write them in two arrays: a numeric and a string array. Then I create constants of those two arrays by right-clicking the indicator and sele
cting "create Constant".

The second attached vi is the one that read the text file with my defined errors and the third attachement is an example of my error text file. This also allows me to have the errors in one place, documented.

Best regards
Enrique
www.vartortech.com
Message 6 of 11
(4,049 Views)
I've used this method before also. However not all LabVIEW errors are positive. I believe the range from 5000-9999 is specified as user defined error codes.
0 Kudos
Message 7 of 11
(4,049 Views)
Ok. I think I was mislead in my interpretation of the phrase "database" that I had read before. I have had more experience with relational databases, like M$ SQL Server and Oracle, so I tend to think that a database is referring to that.

Thanks for everybody's help!
Naveen
0 Kudos
Message 8 of 11
(4,049 Views)
Right. It should read that most of LabVIEW errors are positive.
www.vartortech.com
0 Kudos
Message 9 of 11
(4,049 Views)
Actually the easiest thing to do here is create a *-error.txt XML file under /user.lib/errors.

LabVIEW 7 includes a utility under the tools menu to help you with this. I believe the feature less the utility started in LV6 (though I am not sure). It should not be too hard to find information about the XML structure if you do not have the utility.

Errors defined this way will then behave exactly as built in errors. In fact this is where built in errors come from.
0 Kudos
Message 10 of 11
(4,049 Views)