01-13-2011 04:14 PM
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.
01-13-2011 04:58 PM
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.
01-14-2011 08:01 AM
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
01-14-2011 10:14 AM
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.