Skip to content

Commit

Permalink
Fix unhandled exceptions in lambdas being handled
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Apr 12, 2024
1 parent 8ae1301 commit adbe15e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bugsnag/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,12 @@ def report_timeout_to_bugsnag():
return real_handler(aws_event, aws_context)
except Exception as exception:
if self.configuration.auto_notify:
self.notify(exception)
self.notify(
exception,
unhandled=True,
severity='error',
severity_reason={'type': 'unhandledException'},
)

raise
finally:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,7 @@ def my_handler(event, context):
payload = self.server.events_received[0]['json_body']
event = payload['events'][0]

assert event['unhandled']
assert event['exceptions'][0]['message'] == 'oh dear'
assert event['metaData']['AWS Lambda Event'] == {'a': 1}
assert event['metaData']['AWS Lambda Context'] == {
Expand Down Expand Up @@ -1878,6 +1879,7 @@ def my_handler(event, context):
payload = self.server.events_received[0]['json_body']
event = payload['events'][0]

assert event['unhandled']
assert event['exceptions'][0]['message'] == 'oh dear'
assert event['metaData']['AWS Lambda Event'] == {'z': 9}
assert event['metaData']['AWS Lambda Context'] == {
Expand Down

0 comments on commit adbe15e

Please sign in to comment.