我使用异步模块创建了节点lambda函数,并将其附加到step函数。我的lambda如下所示
exports.handler = function (event, context,callback) {
var record =event
async.series(
[
function (callback) {
SomeErrorFunction(record, callback);
}
],
function (err, results) {
if (err){
function LogError(message) {
this.name = "CustomError";
this.message = message;
}
LogError.prototype = new Error();
var error = new LogError('There is an error');
console.log('error is -> ' + JSON.stringify(error));
callback(error)
}
else {
console.log('RESULT -> ' + results);
callback(null,record)
}
});
};
我的脚步是这样的
"MyLambda": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-west-1:12345678:function:MyLambda",
"Next": "MyNextLambda",
"Catch": [ {
"ErrorEquals": ["States.ALL"],
"ResultPath": "$",
"Next": "LogError"
} ]
},
我的问题是出现错误时,错误详细信息不会返回到步骤功能。我可以从console.log('错误是->'+ JSON.stringify(错误))中看到结果;在coludwatch中。但是回调(错误)不会在步骤中返回。相反,步进功能会显示以下消息
{
"error": "Lambda.Unknown",
"cause": "The cause could not be determined because Lambda did not return an error type."
}