LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to show all possible errors generated by a given VI

Is there a way to show all possible errors that any specific VI can generate?  This would be extremely helpful for improving the overall robustness of a given program and it's sub VIs.

 

I am doing engine testing, and it is critical that all internally generated errors be dealt with on a case-by-case basis (for every possible case), so as to avoid locking up or crashing the program during testing. As long as an error has occurred at least once, it is known, and can therefore be dealt with in the code. However, there is always the lingering doubt that there could possibly be a new unknown error that hasn't yet occurred, that could suddenly crash the code.

 

Any help on this topic is greatly appreciated.

 

-Will

pocket_will
0 Kudos
Message 1 of 18
(3,320 Views)

There are thousands of error codes in LabVIEW (including all the hardware drivers, communication protocols, etc).  If you know which VIs your code uses you might be able to limit the possible errors somewhat, but I wouldn't want to rely on catching every possible error code.  Robust code can handle an unexpected error.

0 Kudos
Message 2 of 18
(3,317 Views)

I understand that there are thousands of possible error codes in LabVIEW.  Presumably however, each VI (ie. the LabVIEW palette of subVIs) can only generate a smaller subset of those thousands. This is what I'm after. Exactly because there are so many, it is critical to know which errors are possible from a specific VI in order to narrow it down and handle them on a case-by-case basis.

pocket_will
0 Kudos
Message 3 of 18
(3,312 Views)

You'd have to dig down inside each VI in the palettes and look at every subVI inside them.  In addition some of the error codes vary from one operating system to another and might even be different between versions of the same operating system (for example Windows XP versus 7) or different configurations.  For example the open file function could generate different errors depending on file system permissions which could be different even on the same operating system depending on which user is logged in and how the machine is administered or connected to the network (I'm not certain this is the case, but I would not want to rely on it always returning the same error when it cannot open a file).

 

This path leads to code that is brittle, not robust.  Consider trying to handle the effect of an error occurring from a particular node, instead of worrying about exactly which error it was.  For example, if you get an error because you can't open a file, you should not need to know exactly why it happened.  It might be helpful to know the reason when it's available, but your code shouldn't fail just because it doesn't know why it couldn't open the file.

0 Kudos
Message 4 of 18
(3,309 Views)
I think we're talking a bit of semantics here. A list of either (a) every possible error and their error codes or (b) every type/category/mode of error essentially gives the programmer the same information, which is how to anticipate any type of error and write robust code.

In some cases (ie. some network communication VIs in the TCP palettes), it is very difficult, nigh impossible, to anticipate every type of error.

In any case, either there is or there isn't a way to find all the errors from a given VI. That is my question.
pocket_will
0 Kudos
Message 5 of 18
(3,301 Views)

@Will_C wrote:
In any case, either there is or there isn't a way to find all the errors from a given VI. That is my question.

No, there's no tool that you can point at an arbitrary VI to find out every error that it could generate.

 

EDIT: meant to reply to the first part of your message, too:


@Will_C wrote:
I think we're talking a bit of semantics here. A list of either (a) every possible error and their error codes or (b) every type/category/mode of error essentially gives the programmer the same information, which is how to anticipate any type of error and write robust code.

I'm suggesting that you should look at the function that generates the error, not the error code itself, to determine the appropriate response, since there's no way to get from an error code to a category of error.  So no, I don't think this is semantics, and your two options are not the same information.  But I also cannot imagine the size of the case structure that would be required to handle every possible error; it would quickly become unmanageable.

0 Kudos
Message 6 of 18
(3,297 Views)

Unless you talk about very trivial libraries, there is never an exhaustive documentation of possible error codes in any programming system I know of. The variables are simply to big, the effort to maintain such information absolutely unjustified, as code is modified, new platforms added that can suddenly cause all kinds of new and different errors, and those platform APIs never document the errors in an exhaustive manner either, if they even document any specific error codes. Often it is more of the type returns 0 on success and an error code otherwise.

 

Even if such a documentation would exist, it would serve no good purpose, as I'm sure nobody would want to wade through pages and pages of error codes for every function called, and implement an unwieldy case structure to react on those error codes. It also is a sure way to make your code break at the slightest change of anything in your system, even a simple security bug fix to your OS added by automatic upgrade that suddenly introduces new error codes or even changes them for whatever reason.

 

Robust programming does not react on error codes, but on error situations at specific locations in your code. There is little help in knowing that you have a file permission error somewhere in a 2 hour procedure. It is much more helpfule to know that trying to open the data file to store the measurement results has failed, or that some measurement parameters couldn't be accessed. The error code can then give extra information as to the possible cause, but isn't the most interesting information in the first place.


Reacting on specific error codes only makes sense in very specific situations such as timeout errors that often simply can be ignored and then attempting to retry the operation, or if you want to detect specifically if you are able to access a certain file location with certain access rights and similar things. Here the error code is used to detect that something specific has happened that is an error in the context of the function, but absolutely legitime and expected behaviour under the conditions you are wanting to use that function.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 18
(3,234 Views)

This is an old thread, and unfortunately still valid.

 

It is OUTRAGEOUS that NI doesn't provide documentation for each and every VI telling what error codes they can return. I'm still amazed that the user community hasn't forced NI to start documenting their own code. Simply giving us a list of thousands of codes and saying "we return codes from this list" is absolutely unacceptable.

 

How can I know my code handles every possible error code from a call, without knowing what they are?

 

LabVIEW *still* isn't a programming language; it's a TOY.

 

And lest you believe rolfk, who said "there is never an exhaustive documentation of possible error codes in any programming system I know of", let me refer you to (for instance) UNIX man pages, which list errno's that can be returned by system calls.  Here's that portion of the Linux close(2) man page. This is what we want for LabVIEW. What makes NI think this is so difficult? Maybe because for years NI's R&D group has been, well, lazy?

 

ERRORS     

       EBADF  fd isn't a valid open file descriptor.

       EINTR  The close() call was interrupted by a signal; see signal(7).

       EIO    An I/O error occurred.

       ENOSPC, EDQUOT
              On NFS, these errors are not normally reported against the
              first write which exceeds the available storage space, but
              instead against a subsequent write(2), fsync(2), or close().

       See NOTES for a discussion of why close() should not be retried after
       an error.
 

 

0 Kudos
Message 8 of 18
(2,439 Views)

@Provisio wrote:

And lest you believe rolfk, who said "there is never an exhaustive documentation of possible error codes in any programming system I know of", let me refer you to (for instance) UNIX man pages, which list errno's that can be returned by system calls.  Here's that portion of the Linux close(2) man page. This is what we want for LabVIEW. What makes NI think this is so difficult? Maybe because for years NI's R&D group has been, well, lazy?

 

ERRORS     

       EBADF  fd isn't a valid open file descriptor.

       EINTR  The close() call was interrupted by a signal; see signal(7).

       EIO    An I/O error occurred.

       ENOSPC, EDQUOT
              On NFS, these errors are not normally reported against the
              first write which exceeds the available storage space, but
              instead against a subsequent write(2), fsync(2), or close().

       See NOTES for a discussion of why close() should not be retried after
       an error.
 

 


How confident are you that is the complete list? (Let's leave aside that you probably have to include some other header to get something to compare those codes to)

Presumably the man page is just written text. It could be out of date, etc.

If you really want to be paranoid, you'd have to read the code that compiles the call. And then anything that calls. And then... and then... you get the picture.

 

With LabVIEW, there are a few common error codes for most functions (by which I mean, a given function has a few common errors typically). It'd be nice to have a list, and in some cases there are suggestions of lists (e.g. Network Streams Error Codes) but I wouldn't inherently rely on that being exhaustive.

It may be those are all the errors thrown by design by those functions, but if I want to handle my code's execution carefully, I need to have some error handling that handles the default case.

 

Beyond that, some depend on various other details (things involving the memory manager come to mind). Some things can cause errors that cannot be passed to an error wire (because the node has no error out), e.g. I believe if you run out of memory, arithmetic nodes might be able to pop up the dialog indicating oom. Build Array is a more typical culprit, but you can't handle that error - only avoid it. You could, if you wanted, look at available memory (perhaps using OS-specific functions) and guess when you were about to have a problem.

 

I'd suggest that rather than being "lazy", the absence of a list is intended to prevent false reliance on an incomplete (or potentially inaccurate - although you could claim that fails under lazy) list of possible failures (especially in critical applications).


GCentral
0 Kudos
Message 9 of 18
(2,425 Views)

A nice rant! Because that is what this post is!

If I understand you correctly you add after each function call in C a case statement where you carefully list all the documented error codes and then post an according message for each code to stderr? Sounds like the way to go.

Aside that I don’t trust the manpages to be exhaustive but at most indicative (your error handling code of course never has a default case right?) and clib from Linux is in many aspects different enough to other Unix implementations such as BSD and that is different to others, etc.this kind of error handling is not only totally unportable but would also get quickly totally unmaintainable. Are you planning to revisit your entire code base every time you link it with a new version of clib?

Generally speaking functions can return all kind of errors. Some specific errors can sometimes mean something specific depending on the context you call it and you do want to handle that error in a specific way such as retrying the operation or ignoring it in some cases (communication timeouts for instance). Everything else is typically an error that should not have happened and the only useful recourse is to log the error and inform the user and/or restart the operation completely.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 18
(2,418 Views)