Better example code?
@ericzbeard 已經在處理了。
開始於 2022年10月13日。
評估
這個 Issue 還沒有評估資料。
描述
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
- 主要語言
- Python
- 星號
- 107
- 分支
- 46
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aws-cloudformation/cloudformation-cli-python-plugin 的其他 Issue
-
Support UV未關閉
難度 2/5 1-3 小時 新手友好度 78/100
-
Repo alive?未關閉
難度 5/5 一週以上 新手友好度 20/100
aws-cloudformation/cloudformation-cli-python-plugin#270 · 1 則留言 · 1 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 45/100
-
難度 3/5 1-2 天 新手友好度 35/100
aws-cloudformation/cloudformation-cli-python-plugin#268 · 1 則留言 · 2 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 35/100
aws-cloudformation/cloudformation-cli-python-plugin#264 · 1 則留言 ·
查看 aws-cloudformation/cloudformation-cli-python-plugin 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 85/100
mozilla/bedrock#17413 · 1 個 reaction ·
維護者通常 2 天內回覆
-
instance instance add
難度 2/5 1-3 小時 新手友好度 68/100
searxng/searx-instances#943 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
bug tools
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
lance-format/lance#9655 ·
維護者通常 2 天內回覆