Jump to content

How do you typically set the values of an error cluster?


  

52 members have voted

You do not have permission to vote in this poll, or see the poll results. Please sign in or register to vote in this poll.

Recommended Posts

This thread is about generation of errors. Please do not tangent off into handling of errors, except insofar as generating one error to replace one from upstream is a form of handling. I'm asking this question partially as LV R&D, with an eye to the future, but more as a CLA user with an eye to writing code that is good style.

In the question about dropping warnings, this is the type of programming that I mean:

post-5877-0-46110900-1300297682_thumb.pn

Link to comment

When a subVI needs to create an error to return to caller, how do you typically set the values of the error cluster (you may check multiple)?

Other: I typically I use the Build Error Cluster__ogtk.vi along with the Error Codes Ring constant__ogtk.vi.

Link to comment
I typically I use the... Error Codes Ring constant__ogtk.vi.

Me too - it's invaluable. Much easier than trying to hunt down an appropriate error code, and your BDs are more readable (I've seen people create their own 5000 series error codes rather than looking for an existing code).

Link to comment

I think warnings are a double edged sword. For example. How many people turn off warnings on the LabVIEW error dialogue unless you are optimising? I prefer prioritised errors since the default Labview handling for errors will pop-up dialogues which then forces you to consider the seriousness of the error. It also enables you to do things like graceful degradation. Warnings, however, don't really give you much apart from the headache of documentation explaining what it means..

Edited by ShaunR
Link to comment

We use errors to indicate a task failure, so all subsequent operations are not performed. Because of this, we NEVER overwrite an error or change its code because it makes it hard to determine the origin of the error. We use warnings to alert the user of non-critical things (i.e. "Your DAQ card will require calibration in 30 days, contact QA for a replacement"). If an error is generated after a warning, the warning is overwritten.

To handle all of this logic, we use this VI to create an error:

post-9124-0-22251000-1300373488_thumb.pn

It has the features:

  • can create error or warning
  • code is an enum (similar to ogtk enum)
  • created errors will overwrite warnings
  • created error will not overwrite previous error
  • created warning will not overwrite previous warning
  • call chain is included in error source
  • optional custom text can be pre-pended to source

typically we create a 42:generic error and just describe it with custom text or error details (i.e. Excel tab "foo" is not found)

Note: our software is used internally, so we are always a phone call away to describe what an error message means so messages can be a little more cryptic. if you are producing software for external release, you will have to generate messages that are a little more user-friendly

Edited by bazookazuz
Link to comment

I find it hard to believe that anyone claims never to overwrite errors. I'm not sure how you detect the presence or absence of a file without trying to open it, getting error 7 and then filtering it. I suppose you could list the containing folder, but that seems a lot harder. There's nothing wrong with the former method of generating an error and then clearing it.

In addition there are plenty of routines that can throw a User Cancel error as a normal part of user interaction. So maybe the clarification is that you should never overwrite an unexpected error.

We have a Filter Error function that is useful. I've never figured out why this hasn't been added to vi.lib. The clear errors function clears all errors, but you should only be clearing expected ones!

As far as generating errors, we have one that dumps the calling path into the error source, which I'm sure is pretty common. What it also does is that you can wire anything into it, and it uses the OpenG Lvdata tools to serialize the arbitrary data to a string, and then you can get a data dump in the error message.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.