Thread: Error Clusters
View Single Post
  #2   Spotlight this post!  
Unread 17-08-2012, 20:12
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Error Clusters

Sorry if the write-ups don't make sense.

The error cluster datatype is basically a fancier error code with a Boolean indicating if it is an error or not, an integer code to define the error, and a string to describe the source of the error. When an error occurs, the information is passed or sorta thrown forward to dependent code until some code clears it.

This works similar to try/catch, but the try block is defined not by a range of lines of code, but rather by the flow of the error I/O wire. Blocks that share the same error I/O are in the same try block. The catch happens when a the error chain breaks and is handled, displayed, or cleared. Unlike throwing an exception to the catch block, the error I/O is propagated via wire, allowing downstream blocks to produce appropriate outputs, shut things down, etc. In reality, there will sometimes be mini-catch sections that operate a bit of code and then the primary one that will finally clear it by not propagating it further. Also, the downstream code may not be linear, and the error may propagate to parallel branches each with its own handlers.

To add FRC specific error codes, there would ideally be an example showing how. And in fact, there may even need to be a few additional things added so that it is simple to extend the error codes. This is a good request. I'll capture it and see if we can get to it.

In the meantime, the basics are that if you write a VI to control an arm, and an arm update cannot be carried out, it can return an error by setting the Boolean and set the code to something meaningful to you. You can also put any text you like into the source string. Provided downstream code doesn't clear it, the error will show up in the Diagnostics. Let me know if you see otherwise or have other questions.

Greg McKaskle
Reply With Quote