Jump to content

Article - Put Error Handling in Every SubVI


BobHamburger

Recommended Posts

QUOTE (BobHamburger @ Sep 9 2008, 12:23 AM)

Agreed!

We go a step further and use functions that check the error boolean and log the error to file when detected. The log file is the first place I check if things go badly

AND

It's the first place I check if the app runs fine.

It also lets me "see" the error after the fact, like when the customer from two years ago sudenly runs into a problem.

I can't count the number of times engineers have returned from delivering an app saying "I love that Event Logger!"

Ben

Link to post

QUOTE (neB @ Sep 9 2008, 12:50 PM)

It also lets me "see" the error after the fact, like when the customer from two years ago sudenly runs into a problem.

I can't count the number of times engineers have returned from delivering an app saying "I love that Event Logger!"

Ben

I totally agree with that, you can't seriously ship a system to a customer without some kind of event logger.

The time spent on this is saved hundreds of times when you have many system out in the industry !

Link to post

Error handling is great, and we use it just about everywhere, especially if there is any I/O or any chance for invalid arithmetic results. But if the routine does not have any need for error handling, then I think it is counterproductive to add it. If you were writing "Trim Whitespace.vi" for your own library, would you add error handling?

Some of our code just converts between data structures, and those absolutely need to be in subvis so that the conversion is encapsulated. However there is usually no need for error handling. If there is bad data in the cluster, there will usually be an error thrown somewhere nearby, and it doesn't matter whether the conversion itself operates on an empty cluster.

Link to post

QUOTE (jdunham @ Sep 9 2008, 12:58 PM)

Error handling is great, and we use it just about everywhere, especially if there is any I/O or any chance for invalid arithmetic results. But if the routine does not have any need for error handling, then I think it is counterproductive to add it.

I have to agree. Adding error handling to every VI whether it needs it or not is unnecessary and overly-complicated. Adding unnecessary error handling inputs/outputs is syntactically equivalent to just putting everything inside a sequence structure. It's just that it looks tidier because the icon is smaller than the structure.

Link to post

QUOTE (jdunham @ Sep 9 2008, 01:58 PM)

If you were writing "Trim Whitespace.vi" for your own library, would you add error handling?

As usual, my answer is "it depends" :) Error cases are important when used appropriately, and I agree that that wrapping all VIs in error cases can be overkill.

Link to post

Join the conversation

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

Guest
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.