-
Notifications
You must be signed in to change notification settings - Fork 118
Description
I make use of AWS Step Functions to orchestrate my Lambdas, in some cases routing Retry/Catch logic based on specific types of errors that Lambdas throw. AWS documents this behavior here with the following example in NodeJS:
export const handler = async () => {
function CustomError(message) {
this.name = 'CustomError';
this.message = message;
}
CustomError.prototype = new Error();
throw new CustomError('This is a custom error!');
};
Similarly, in Python, the following can be done:
class CustomError(Exception):
pass
def lambda_handler(event, context):
raise CustomError("Test Error")
This will result in the following output:
{
"errorMessage": "Test Error",
"errorType": "CustomError"
}
The AWS Step Function allows Catch/Retry behaviors based on the errorType
that is outputted in the Lambda.
In Swift, the errorType
is hardcoded here to output "FunctionError". This makes it impossible to Catch/Retry in a step function based off of the type of error that was thrown. It is possible to accomplish similar goals in step function by using string comparisons, but this would increase state transitions, and therefore cost.
To solve this issue for my own case, I forked v1 and added the capability in this commit. This fork does accomplish the desired goal, but it is most likely not the most elegant way to do so. I would like to start a discussion on how this behavior could be adopted in the runtime.