LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom error handling - Can I pass a description?

Solved!
Go to solution

Aiming to reduce the frequency with which I litter my code with comments like "#ErrorCode: Place an error here!", always intending to later update the Error Code file, then choose from an error ring rather than just a custom error with a number from the top of my head (in the user range), I'm looking at ways to build a library for simple error handling.

 

I've got something that works semi-reasonably, but since the errors aren't stored in a custom error file, the error indicators refuse to give me a description. Is there something I can do about this other than a) create a custom error file, or b) store the message in the 'source' string?

 

Below is an image of one of the VIs I've written. It passes errors to an Actor for logging and pushes an error onto the Error Out indicator - it is called indirectly by VIs in other places which ideally should just need a boolean (error or warning?) and an error code (I32 coercion from enum is the current plan). I also tried using the General Error Handler (with a bundle-by-name after to force the status flag) but this also doesn't add a description. The message is found in either case, but I can't get it to an indicator, only to my logger via the message I've set up. Should I be happy with this? I suppose often error indicators are not visible, either being hidden or in subVIs with closed FPs...

 

eHandler.png

 

Edit: There should be a 'Equal to Zero?' check on the Code before execution, otherwise I get the source with a 0 code and warning...


GCentral
0 Kudos
Message 1 of 10
(4,353 Views)

Create the custom error file then make sure to include it in you SCC and deployments

 

I've gotten into the habit of adding a ReadMe.txt in the SCC repository to reserve error code ranges by library. Then create 1 error file per project eg mycoolFoo_errors.txt the source should disambiguate any accidentally duplicated codes that refer to vis not in mycoolFoo.lvlib


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(4,338 Views)

Is the recommended method for using these in the development environment to just sym/hard link each error file into user.lib? (and then remove them after testing during deployment?)

 

I took a look back into VIPM's settings and see that I can set the file in 'Source File Settings' to be installed as a 'Custom Error' destination, which defaults to <LabVIEW>\project\errors\<category>\<package name> as far as I can see - I guess that this will solve any problems with deployment even without building an executable/application.


GCentral
0 Kudos
Message 3 of 10
(4,314 Views)
Solution
Accepted by topic author cbutcher

Try these.

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

Aha! At first, I was disappointed by not being able to use your awesomely shaped icons, but then, googling for <append> tags, I learned how they should be used, and tried setting 'Append' to false. Now, it works beautifully!

 

The link I found useful was here: https://forums.ni.com/t5/LabVIEW/error-handling-basic/td-p/1050205


GCentral
Message 5 of 10
(4,275 Views)

@cbutcher wrote:

Aha! At first, I was disappointed by not being able to use your awesomely shaped icons, but then,


Oh then try to find out how to get those nasty coersion dots out of the way.:D. That was a unique use of the new (then) native recursion feature:)

 

If you actually find that post.  It's another one I failed to tag so, posting a Link= kudos


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(4,267 Views)

Are you looking for something like this?

(Note: To make this handy, put a launcher in the "...\National Instruments\LabVIEW 2016\project\" folder that calls "Find Coercion Dots.vi".)

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

@paul_cardinale wrote:

Are you looking for something like this?

(Note: To make this handy, put a launcher in the "...\National Instruments\LabVIEW 2016\project\" folder that calls "Find Coercion Dots.vi".)


No Kudos for you today

 

This took me a while to find by digging though here


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(4,244 Views)

I interpreted "get those nasty coersion dots out of the way" to mean 'get rid of those nasty coercion dots'.  It never occurred to me that someone would want to move them around.

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

@paul_cardinale wrote:

I interpreted "get those nasty coersion dots out of the way" to mean 'get rid of those nasty coercion dots'.  It never occurred to me that someone would want to move them around.


Smiley LOL

I don't recommend the vi


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(4,227 Views)