Better example code?
@ericzbeard ci sta già lavorando.
Dal 13/10/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 107
- Fork
- 46
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws-cloudformation/cloudformation-cli-python-plugin
-
Support UV Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Repo alive? Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
aws-cloudformation/cloudformation-cli-python-plugin#270 · 1 commento · 1 reazione ·
-
Improve docstrings for Hooks Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws-cloudformation/cloudformation-cli-python-plugin#268 · 1 commento · 2 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws-cloudformation/cloudformation-cli-python-plugin#264 · 1 commento ·
Tutte le issue di aws-cloudformation/cloudformation-cli-python-plugin
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
learningequality/ricecooker#747 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
run-llama/llama_index#23199 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
KhronosGroup/glTF-Blender-IO#2769 ·