You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make socket binding exceptions more debugable #2104
Is your feature request related to a problem? Please describe.
When you hit an OSError, unless you have debug log level tracing enabled your client code may wind up with a bare OSError with little context for what bus was responsible. When more than one bus is involved in your system you're left to disambiguate with some custom code of one's own.
Describe the solution you'd like
I'd like the OSError to have a note added to it with the necessary context to identify what bus channel was involved with the error. A perfect solution would be to augment the logic defined here
log.debug("Binding socket to channel=%s", channel)
sock.bind((channel,))
log.debug("Bound socket.")
and replace it with
601c601,607< sock.bind((channel,))---> try:> sock.bind((channel,))> except OSError as exc:> exc_msg = f"Error binding socketcan bus at {channel=}"> log.exception(exc_msg)> exc.add_note(exc_msg)> raise604d609<
Describe alternatives you've considered
none
Additional context
Consider any other areas of the python-can codebase that similarly raise naked python errors without context. Those should also benefit by injecting notes with the surrounding context that was being attempted.
Activity