View Single Post
  #3   Spotlight this post!  
Unread 15-02-2012, 17:10
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
Re: Exception Handling Best Practice

While you shouldn't ignore the exceptions which crop up, that doesn't mean you have to handle them - when possible, I just declare them as thrown all the way up to the top. If something happens, it will crash the robot.

This might sound like a bad thing, but the common exceptions, like those thrown by the functions to create an AnalogChannel, etc, are configuration problems and wouldn't be likely to be recoverable anyway.

The other common one is InterruptedException. You might not be able to throw it (if you get one in the inhereted method of Runnable.run()), and in this case, you should feel safe just eating it - catch it and do nothing. The only thing that will generate an InterruptedException on the cRIO would be user code, as in, you would have to explicitly interrupt that thread for it to happen.

When in doubt, just throw it.
Reply With Quote