Menu

#3 catch IllegalArgumentExceptions

3.0
closed
None
2015-11-23
2015-02-07
No

Maybe those should all catch IllegalArgumentExceptions and set an appropriate error_code:

  • ThermoElectricCollerFeatureAdapter::setTECTemperature
  • SpectrometerFeatureAdapter::setIntegrationTimeMicros
  • EEPromFeatureAdapter::readEEPROMSlot

Discussion

  • Aaron Gage

    Aaron Gage - 2015-11-14

    I agree. There are quite a few places where IllegalArgumentExceptions are being thrown and these need to be trapped so they don't blow up at the API layer. This goes for every kind of exception, but I expect that most of the offenders will be IllegalArgumentExceptions.

    I'm not sure yet whether this should be handled with "Pokemon handlers" at the top (catch them all with try {} catch (Exception &ex)) or if these should be done more surgically so that the error codes can be assigned more appropriately. I am leaning towards the latter, but that means I won't be getting to it as fast.

     
  • Aaron Gage

    Aaron Gage - 2015-11-23
    • assigned_to: Aaron Gage
     
  • Aaron Gage

    Aaron Gage - 2015-11-23

    Created the amg-exceptions-3 branch to work on this. So far, I think I have cleaned up all of the offending IllegalArgumentExceptions and also took care of a NumberFormatException that wasn't being handled.

    I dealt with this by adding explicit IllegalArgumentException references to the various throw() declarations where they were actually could be thrown, and tried to add handlers to all of the callers. I think I got all of them. Since C++ does not really do statically checked exceptions, adding to the throw() lists is probably a useless exercise, but I consider it to be a form of documentation for the moment.

     
  • Aaron Gage

    Aaron Gage - 2015-11-23

    The branch was merged (234:236) back to trunk at revision 242 and resolved at 243. Closing this issue.

     
  • Aaron Gage

    Aaron Gage - 2015-11-23
    • status: open --> closed
     

Log in to post a comment.