Add debugging utilities to print exception tracebacks
Closes #246 (closed)
Summary
This is a debugging utility for Axii developers only. It should help to detect infinite loops or other hard-to-find exceptions by printing stacktraces when enabled.
- New in module
armarx_setup.core.error
: Functionhandle_exception(expected_because: ty.Optional[str] = None) -> None
- New global config option
print_exception_traceback
Intended Usage
For every "except" block, do the following:
try:
something_which_might_fail()
except error.ConcreteError:
error.handle_exception()
other_error_handling()
Optionally, a reason can be supplied why this exception type is expected using expected_because
.
Behaviour and Effects
-
dev_mode
is off andprint_exception_traceback
is off (default): No effect for end user -
dev_mode
is on andprint_exception_traceback
is off: No effect for end user and Axii developers -
dev_mode
is on andprint_exception_traceback
is on: Tracebacks are printed
Printing Rules
Using RichConsole (Default)
Output when running axii w ug
without active workspace
Using StdConsole (Fallback)
Output when running axii w ug
without active workspace
expected_because
Was Set
Collapsed View If Output when running a subprocess with process.execute(...)
(expected exception on subprocess termination). A little hint is given with the supplied reason why this exception is expected, but no further traceback is provided.
Future Work
In the future, we can add an exception-logging-to-disk mechanism to attach to issues or for post-mortem introspection