keenon / AddBiomechanics

A tool to automatically process and share biomechanics data
https://addbiomechanics.org/
Other
26 stars 5 forks source link

Reconnect automated exception handling and error message system in backend #223

Closed nickbianco closed 7 months ago

nickbianco commented 7 months ago

Fixes #221

As the title suggests, this PR reimplements the automated exception handling from the old Engine class. Since the new Subject class mostly mimics the old Engine class, I've moved the exception handling stuff there.

There is one minor change from the original implementation to note. Since some of the methods within Subject are essentially helper methods called by other methods, I've added the new EXCEPTION_MAP: only the methods in this map are wrapped with the exception handling logic. These methods should only be the "top-level" methods called by engine.py. Otherwise, an Error will be raised by every helper method in the stack trace and the original exception message from nimblephysics will get buried.

As before, the error messages will get stored in a file _errors.json which can be used to populate the frontend with helpful feedback to the user.

Tested the change on the files recently sent from Marilyn Keller. The change successfully produces the expected RuntimeError added from https://github.com/keenon/nimblephysics/pull/204.