Maybe flatten out exception tree
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Commencez par examiner la hiérarchie actuelle des exceptions ainsi que les modules proposés exceptions.general, exceptions.http, exceptions.opening, exceptions.kv_store et exceptions.acl. Examinez ensuite le générateur et sa gestion des collisions. Le travail est considéré comme terminé lorsque la hiérarchie et les noms sont validés, que l’aplatissement est implémenté sans modification involontaire des relations de parenté et que des protections contre les collisions sont ajoutées.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
This is a ticket for discussion and design, responding to Paul's comment about nested exceptions being awkward to reach for.
--
I spread all the errors out on the table and had a look. We can get a pretty nice result by dividing exceptions across 5 modules, while still saving ourselves from utterly changing the shape of the world (fighting the WIT forevermore). No more subpackages under exceptions, just 5 files:
-
exceptions.general:- All from types.error. I don't see a point in having a common superclass for these at all; there's no semantic, and it doesn't really help catchers narrow down what threw it, as many things throw these.
- Move
HttpInvalid,HttpUser, andHttpIncompletetoexceptions.http, though. - It's unfortunate
GenericErrorexists, as it sound a lot likeUnexpectedFastlyError.UnexpectedFastlyErrorshould become private, as it indicates a bug in our code if it's thrown. People definitely shouldn't be catching it. CatchExceptionorFastlyExceptionif you want a catch-all. - Rename
GenericErrortoOtherErrorto get a little closer to its meaning. "Generic" suggests to me a superset of the other errors, while "Other" unambiguously indicates it's not one of those errors.
-
exceptions.http:ErrorWithDetailwith a better name, likeHttpError.- All the
send-error-detailexceptionserror-with-detailcarries (not currently generated). Map anyErrorWithDetailthat has (optional) details directly onto these, subclassingHttpError. - All the
trailer-errors. RenameErrortoOtherError.
-
exceptions.opening:- All
open-errorerrors. This is actually a pretty semantically cohesive category.
- All
-
exceptions.kv_store:- All
kv-errorerrors. - There's another
GenericErrorthere. Rename it toOtherError.
- All
-
exceptions.acl:- All the
acl-errors. RenameGenericErrortoOtherError.
- All the
Open questions
- Are we going to cause trouble for ourselves by changing the parentage of some errors, like making
error'sHttpInvalidsuperclassexceptions.http.HttpError(or perhaps some other common ancestor)? I rather think so. The common-ancestor approach sounds good. Theerrorsuperclass is worthless, but theerror-with-detailone may have meaning.
Name collisions (if we were to flatten everything into 1 module):
- Error (x2), but we can probably remove the types.error.Error common superclass to make that go away.
- GenericError (x4)
- LimitExceeded (x2)
- TooManyRequests (x2)
- Unsupported (x2)
Paths not taken
We could deduplicate and have, say, ACL stuff and non-ACL stuff throw the same TooManyRequests error, but we'd be losing potentially important info for the catcher. So that's a bad idea. (Also, it could get messy if the 2 TooManyRequests errors later diverge in shape, which might happen if WIT grows subtyping.)
Thus, we must rename exceptions or divide up into modules.
If we flatten and rename, we get into trouble in the future when somebody introduces another InternalError and we never prefixed the KV one into KvStoreInternalError. I'm against preemptively prefixing the heck out of everything, because it gets wordy and this isn't Java. And does one really need to say HttpTrailerError? There are unlikely to be other kinds of trailer errors. But if we don't prefix universally, it becomes awkward to program against because you constantly have to look aside to see what we named things. So let's keep the names short and just make a better __repr__ instead if needed to clarify tracebacks.
Prerequisites
We'd need to add alarm bells about collisions in the generator so we don't accidentally template duplicate names into one module.
- Langage dominant
- Python
- Étoiles
- 5
- Forks
- 1
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun 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 fastly/compute-sdk-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
fastly/compute-sdk-python#116 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
fastly/compute-sdk-python#98 ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
fastly/compute-sdk-python#74 ·
-
Add HTTP Downstream Metadata APIOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
fastly/compute-sdk-python#61 ·
-
Set up Sphinx Documentation InfrastructurePeut-être à nouveau libre @erikrose l’a pris il y a 186 jours, et aucune pull request n’est ouverte. Ouverte
fastly/compute-sdk-python#60 · 1 personne assignée ·
Toutes les issues de fastly/compute-sdk-python
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 60/100
521xueweihan/HelloGitHub#3924 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
wilbowes/EchoMuse#869 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Claiming namespace `jft63`Ouvertenamespace operations
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
EclipseFdn/open-vsx.org#14043 ·
Les mainteneurs répondent en général sous 1 jour
-
test: TestServeUntilStale races the server's close against the client's sendall (BrokenPipeError under load)Peut-être pris @evoludigit l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 89/100
Les mainteneurs répondent en général sous 1 jour