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.
Fixes #221
As the title suggests, this PR reimplements the automated exception handling from the old
Engine
class. Since the newSubject
class mostly mimics the oldEngine
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 newEXCEPTION_MAP
: only the methods in this map are wrapped with the exception handling logic. These methods should only be the "top-level" methods called byengine.py
. Otherwise, anError
will be raised by every helper method in the stack trace and the original exception message fromnimblephysics
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.