Skip to content

Add debugging utilities to print exception tracebacks

Christian Dreher requested to merge feature/dev-mode-exception-stacktraces into main

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: Function handle_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 and print_exception_traceback is off (default): No effect for end user
  • dev_mode is on and print_exception_traceback is off: No effect for end user and Axii developers
  • dev_mode is on and print_exception_traceback is on: Tracebacks are printed

Printing Rules

Using RichConsole (Default)

Output when running axii w ug without active workspace

image (continued) image

Using StdConsole (Fallback)

Output when running axii w ug without active workspace

image

Collapsed View If expected_because Was Set

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.

image

Future Work

In the future, we can add an exception-logging-to-disk mechanism to attach to issues or for post-mortem introspection

Merge request reports