I deployed the following code to an AWS Lambda using runtime Python 3.8.
try:
raise Exception('my exception')
except Exception as e:
raise ValueError('my exception 2') from e
In CloudWatch, I expect to see exception chaining like this:
Traceback (most recent call last):
File "/var/task/handler.py", line 2, in <module>
raise Exception('my exception')
Exception: my exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/task/handler.py", line 4, in <module>
raise ValueError('my exception 2') from e
ValueError: my exception 2
Instead, I see only the first exception reported in CloudWatch like this:
[ERROR] ValueError: my exception 2
Traceback (most recent call last):
File "/var/task/handler.py", line 21, in pevm_import_budget_file
raise ValueError('my exception 2') from e
Why isn't the direct cause exception from the from statement showing in the log?