in source/workflow/app.py [0:0]
def workflow_error_handler_lambda (event, context):
try:
logger.info("workflow_error_handler_lambda: {}".format(json.dumps(event)))
if not ShortUUID:
raise Exception('ShortUUID is not set in lambda environment.')
logger.info("Process step function error event for stack with ShortUUID {}".format(ShortUUID))
if not ("detail" in event):
raise Exception('event.detail is missing.')
if not "name" in event["detail"]:
raise Exception('name is missing in event.detail.')
if not "status" in event["detail"]:
raise Exception('status is missing in event.detail.')
if not "executionArn" in event["detail"]:
raise Exception('status is missing in event.detail.')
# only process events for state machines that are part of this stack
if not event["detail"]["stateMachineArn"].find(ShortUUID):
logger.info("Event not processed: This event is not from the stack with ShortUUID {}".format(ShortUUID))
return {}
executions = get_execution_errors(event["detail"]["executionArn"])
message = parse_execution_error(event["detail"]["executionArn"], executions, event["detail"]["status"])
#input = event.detail.input
stateMachineExecution = event["detail"]["executionArn"]
# Check the currently active workflows for this execution arn and set the
# status to error if found.
started_workflows = list_workflow_executions_by_status(awsmie.WORKFLOW_STATUS_STARTED)
for workflow in started_workflows:
if workflow["StateMachineExecutionArn"] == event["detail"]["executionArn"]:
update_workflow_execution_status(workflow["Id"], awsmie.WORKFLOW_STATUS_ERROR, message)
response = {
"stateMachineExecution": stateMachineExecution,
"errorMessage": message
}
logger.info("workflow_error_handler_lambda caught error: {}".format(json.dumps(response)))
return response
except Exception as e:
logger.error("Unable to handle workflow step function error: {}".format(e))
raise(e)