Make socket binding exceptions more debugable
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 75/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- networking
Rechercherichtung
Read can/interfaces/socketcan/socketcan.py around lines 589-602, starting with the socket.bind((channel,)) call and its surrounding error handling. Verify that binding failures retain the channel context in the OSError, then inspect nearby areas of the python-can codebase for similarly context-free Python errors and check that the resulting exceptions remain useful to client code.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
https://github.com/hardbyte/python-can/blob/b4f82abede25ff83376be793a2935c41f81c3869/can/interfaces/socketcan/socketcan.py#L589-L602
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)
> raise
604d609
<
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.
- Vorherrschende Sprache
- Python
- Sterne
- 1.6k
- Forks
- 697
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus hardbyte/python-can
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
hardbyte/python-can#2103 ·
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
hardbyte/python-can#2077 · 1 Kommentar · 1 Reaktion ·
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
hardbyte/python-can#1922 · 1 Reaktion ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
hardbyte/python-can#2102 ·
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
hardbyte/python-can#2092 ·
Alle Issues in hardbyte/python-can
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
Maintainer antworten meist innerhalb von 1 Tag
-
instance instance add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
searxng/searx-instances#941 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
FluidNumerics/fluid-walk-blocker#89 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag