Skip to content

Commit

Permalink
properly handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed Apr 19, 2024
1 parent 60c8c92 commit b870666
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lambdas/step_function_invoker/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import boto3
import os
from aws_lambda_powertools import Logger, Metrics
from botocore.exceptions import ParamValidationError

logger = Logger()
metrics = Metrics()
Expand All @@ -17,14 +18,20 @@ def lambda_handler(event, context):
try:
state_machine_execution_result = step_functions_client.start_execution(
stateMachineArn=STATE_MACHINE_ARN,
input=json.dumps(event),
input=event,
)

return {
"statusCode": 200,
"body": json.dumps(state_machine_execution_result),
}

except ParamValidationError as e:
return {
"statusCode": 400,
"body": json.dumps({"error": "Parameter validation error", "details": str(e)}),
}

except Exception as e:
return {
"statusCode": 400,
Expand Down

0 comments on commit b870666

Please sign in to comment.