【发布时间】:2020-06-02 14:16:33
【问题描述】:
我使用运行时 Python 3.8 将以下代码部署到 AWS Lambda。
try:
raise Exception('my exception')
except Exception as e:
raise ValueError('my exception 2') from e
在 CloudWatch 中,我希望看到这样的异常链:
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
相反,我只看到 CloudWatch 中报告的第一个异常,如下所示:
[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
为什么from 语句中的direct cause 异常没有显示在日志中?
【问题讨论】:
标签: python-3.x amazon-web-services aws-lambda