Make socket binding exceptions more debugable
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 75/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- python
- Domaine
- networking
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1.6k
- Forks
- 700
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de hardbyte/python-can
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
hardbyte/python-can#2103 ·
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
hardbyte/python-can#2077 · 1 commentaire · 1 réaction ·
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
hardbyte/python-can#1922 · 1 réaction ·
-
enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
hardbyte/python-can#2102 ·
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
hardbyte/python-can#2092 ·
Toutes les issues de hardbyte/python-can
Issues similaires
-
Claiming namespace `apoint`Ouvertenamespace operations
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
EclipseFdn/open-vsx.org#13573 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
collective/icalendar#1854 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
rancher/rancher-ai-agent#412 ·
Les mainteneurs répondent en général sous 6 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
TUDelftGeodesy/DePSI#134 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
HenriquesLab/rxiv-maker#335 ·