AndrewAnnex / SpiceyPy

SpiceyPy: a Pythonic Wrapper for the SPICE Toolkit.
MIT License
385 stars 84 forks source link

Better exception ideas #365

Closed AndrewAnnex closed 4 years ago

AndrewAnnex commented 4 years ago

progress towards better exception handling in SpiceyPy

This pr creates a new exceptions file with lots of new exceptions defined with the following hierarchy:

  1. SpiceyPyException, which thinly wraps the old SpiceyError exception class to maintain backwards compatibility
  2. A family of SpiceyPyExceptions mixed in with builtin exceptions like IOError, ValueError, etc for example SpiceyPyIOError
  3. A large suite of SpiceExceptions that are sub classes that inherit from the family of SpiceyPyExceptions, ie SpiceFILEOPENFAILED which is a SpiceyPyIOError

Since all the exceptions are based on the older SpiceyError Exception, existing codebases will be able to maintain the use of SpiceyError catches. With the new hierarchy, exception handling can be more granular down to the specific Spice Exceptions that are defined in SPICE.

Before this pr can be merged, I will likely want to have a new section of documentation to explain the above in a tutorial and to attempt to find any missing Spice Errors defined in the cspice codebase that I have not included so far, and any doc strings for those exceptions I can find.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.02%) to 99.814% when pulling dafd83cbe16b9c4b4bb8f9a52d9ef73bb8e1319e on better_exception_ideas into d0ac60626e956d6f1646799b306f8d3032e0ac95 on master.