Skip to content

Commit

Permalink
chore: add better error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
uptickmetachu committed Dec 14, 2023
1 parent e68276d commit 1fbff78
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lambda_function.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import glob
import json
import logging
import os
import subprocess
import sys
Expand All @@ -14,6 +15,8 @@
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

logger = logging.getLogger("splat")

S3_RETRY_COUNT = 10

sentry_sdk.init(
Expand Down Expand Up @@ -198,6 +201,7 @@ def lambda_handler(event, context):
"isBase64Encoded": False,
}
)
print("output_filepath=", output_filepath)
with open(output_filepath, "rb") as f:
# 5xx responses are normal for s3, recommendation is to try 10 times
# https://aws.amazon.com/premiumsupport/knowledge-center/http-5xx-errors-s3/
Expand Down Expand Up @@ -286,7 +290,7 @@ def lambda_handler(event, context):
)

except NotImplementedError:
print("splat|not_implemented_error")
logger.error("splat|not_implemented_error")
return respond(
{
"statusCode": 501,
Expand Down Expand Up @@ -315,8 +319,7 @@ def lambda_handler(event, context):
)

except Exception as e:
print(f"splat|unknown_error|{str(e)}|stacktrace:")
traceback.print_exc()
logger.error(f"splat|unknown_error|{str(e)}|stacktrace:", exc_info=True)
return respond(
{
"statusCode": 500,
Expand Down

0 comments on commit 1fbff78

Please sign in to comment.