Better example code?
@ericzbeard đang làm issue này rồi.
Từ ngày 13/10/2022.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 107
- Fork
- 46
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws-cloudformation/cloudformation-cli-python-plugin
-
Support UV Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Repo alive? Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
aws-cloudformation/cloudformation-cli-python-plugin#270 · 1 bình luận · 1 reaction ·
-
Improve docstrings for Hooks Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws-cloudformation/cloudformation-cli-python-plugin#268 · 1 bình luận · 2 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws-cloudformation/cloudformation-cli-python-plugin#264 · 1 bình luận ·
Tất cả issue của aws-cloudformation/cloudformation-cli-python-plugin
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
learningequality/ricecooker#747 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
run-llama/llama_index#23199 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
KhronosGroup/glTF-Blender-IO#2769 ·