Better example code?
@ericzbeard y travaille déjà.
Depuis le 13/10/2022.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
This could also be misunderstanding, the current example code in the create_handler looks like:
try:
if isinstance(session, SessionProxy):
client = session.client("s3")
# Setting Status to success will signal to cfn that the operation is complete
progress.status = OperationStatus.SUCCESS
except TypeError as e:
# exceptions module lets CloudFormation know the type of failure that occurred
raise exceptions.InternalFailure(f"was not expecting type {e}")
# this can also be done by returning a failed progress event
# return ProgressEvent.failed(HandlerErrorCode.InternalFailure, f"was not expecting type {e}")
return progress
as far as I can see that will never raise a TypeError. So I feel this code will be better to get people started:
if not isinstance(session, SessionProxy):
# exceptions module lets CloudFormation know the type of failure that occurred
raise exceptions.InternalFailure(f"session should be a SessionProxy")
# this can also be done by returning a failed progress event
# return ProgressEvent.failed(HandlerErrorCode.InternalFailure, f"was not expecting type {e}")
# TODO: put code here
# Setting Status to success will signal to cfn that the operation is complete
progress.status = OperationStatus.SUCCESS
return progress
That shows the same concepts, without having that try except increasing indentation.
Even if it would throw that exception, I don't see the added value of replacing that with a custom exception (it makes debugging harder if we do not re-raise the original exception)
If CloudFormation requires the thrown exception to be from the exceptions, this sort of code will lead to pokemon exception handling (gotta catch them all), and converting unknown exceptions to InternlFailure would be better handled in cloudformation-cli-python-lib
- Langage dominant
- Python
- Étoiles
- 107
- Forks
- 46
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir 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 aws-cloudformation/cloudformation-cli-python-plugin
-
Support UV Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Repo alive? Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
aws-cloudformation/cloudformation-cli-python-plugin#270 · 1 commentaire · 1 réaction ·
-
Improve docstrings for Hooks Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
aws-cloudformation/cloudformation-cli-python-plugin#268 · 1 commentaire · 2 réactions ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
aws-cloudformation/cloudformation-cli-python-plugin#264 · 1 commentaire ·
Toutes les issues de aws-cloudformation/cloudformation-cli-python-plugin
Issues similaires
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Ouvertearea: harness bug status: needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Human-Agent-Society/reef#625 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
learningequality/kolibri#15351 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Name consistency Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
eellak/triplestore#65 · 1 commentaire ·