每当AWS Lambda中出现错误(内置错误或自定义错误)时,都会构造并返回错误消息。错误消息包含字段errorType,errorMessage和stackTrace。我想将我的代码包装在try / except块中,并在我引发错误之前添加其他字段,但无法找到一种方法。知道如何做到这一点?
try:
some_function()
except Exception as e:
# Pass additional information/add fields into e
# Something like e['additional_data'] = 'something'
raise e