LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use custom error code?

I followed the link http://zone.ni.com/devzone/cda/tut/p/id/3209 and created some custom error code. But how to use the custom error code correctly?

 

I used it in the following way and didn't get the expected custom error code.

 

set custom error code 5002 means Serial Port Read Failure

in the case serial port read fails, use General Error Handler to combine the "user-defined codes" and "user-defined descriptions".

fail the serial port read on purpose (here the custom error code 5002 is expected but didn't happen)

 

Did I use the custom error code properly?

 

Thank you a lot.

 

0 Kudos
Message 1 of 4
(2,781 Views)

When you detected the error in the program did you change the error code itself on the error output? If not, it would still use the LabVIEW error code for the error, not yours.



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 2 of 4
(2,776 Views)

Thank you. It seems only the inputs "error code" and "error source" of General Error Handler are necessary to use custom error code.

 

I don't understand what the purpose is to set the inputs "user-defined codes" and "user-defined descriptions" as mentioned in the tutorial http://zone.ni.com/devzone/cda/tut/p/id/3209

0 Kudos
Message 3 of 4
(2,744 Views)

This is to allow you (the user) to define error codes that aren't already existing, i.e. you have created a routine for initializing some non-National Instruments' hardware and when it returns an error number the "user error code" allows you to have a meaningful message. It really isn't to replace the existing "built in" error codes. More like your making a dll call to talk to some piece of hardware, a flux-capacitor controller, and it returns an error number 42. You can detect that error number, and having the hardware vendor's explanation ("an error 42 indicates the end of life, the universe and everything") you can create a custom error number, 5002, to pass on the error cluster "bus". Since you have defined this in the "user errors", it will then display the error message to the user.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 4
(2,732 Views)