pycyphal.util.error_reporting module

pycyphal.util.error_reporting.set_internal_error_handler(handler: Callable[[BaseException], None] | None) None[source]

Register a callback that will be invoked whenever an internal pycyphal component encounters an exception somewhere in background asyncio tasks.

This is useful to be notified when something goes wrong while receiving messages in the background etc.

pycyphal.util.error_reporting.handle_internal_error(logger: Logger, e: BaseException, msg: str = '', *args: object) None[source]

Report an internal error: log it via the provided logger and invoke the registered error handler.

Parameters:
  • logger – The logger to use for logger.exception.

  • e – The exception to report.

  • msg – Optional context message describing where/why the error occurred. Defer any formatting for this functions, to also properly handle cases where you print something and its __repr__/__str__ raises an exception.

  • args – Optional arguments for the context message.