Skip to content

Instantly share code, notes, and snippets.

Last active June 26, 2023 09:31
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Professional Lambda Function
import sys
import logging
import traceback
import json
logger = logging.getLogger()
def lambda_handler(event, context):
'''Simple Lambda function.'''
try:'event: {event}')
artist = event['artist']'The artist is: {artist}')
return {"status": "success", "message": None}
except Exception as exp:
exception_type, exception_value, exception_traceback = sys.exc_info()
traceback_string = traceback.format_exception(exception_type, exception_value, exception_traceback)
err_msg = json.dumps({
"errorType": exception_type.__name__,
"errorMessage": str(exception_value),
"stackTrace": traceback_string
Copy link

In the same way you return a status of "success" in the happy path scenario, should you return some other status value when you catch an exception?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment