keenon / nimblephysics

Nimble: Physics Engine for Biomechanics and Deep Learning
http://www.nimblephysics.org
Other
403 stars 44 forks source link

Replace `exit(1)` with exception macros #183

Closed nickbianco closed 1 year ago

nickbianco commented 1 year ago

This PR introduces some changes so that we can more gracefully handle failures in when using the nimblephysics algorithms in AddBiomechanics.

  1. Added (well, modified) the new macos NIMBLE_THROW and NIMBLE_THROW_IF which throw a std::runtime_error (for the latter macro, upon a condition resolving to true). AddBiomechanics uses pybind11 which will automatically cast the std::runtime_error as a Python Exception, which we can then handle appropriately.
  2. Replace all "Release"-level usages of exit(1) with these new macros, so that failures don't kill the entire AddBiomechanics processing pipeline.