【发布时间】:2021-04-20 04:51:16
【问题描述】:
我的 AWS step 函数有以下流程,我的 Python lambda 应该如何引发 MyCustomError?
只使用raise Exception("MyCustomError")?还是我需要做点别的? https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html 的官方文档使用 node.js 作为示例,我没有看到任何 Python 示例。
{
"Comment": "A Hello World example of the Amazon States Language using an AWS Lambda function",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:FailFunction",
"Retry": [ {
"ErrorEquals": ["MyCustomError"],
"IntervalSeconds": 1,
"MaxAttempts": 2,
"BackoffRate": 2.0
} ],
"End": true
}
}
}
【问题讨论】:
-
猜测一下,将
MyCustomError定义为Exception的子类,然后是raise MyCustomError()。
标签: python amazon-web-services aws-lambda aws-step-functions