例如:
try:
...........
# this exception could be thrown from another method, or just a plain Exception
raise xxxException({'code': 400, 'error': 'Very common message'})
except xxxException, e:
ret = {'code':'The code in e', 'error': 'some specific information'}
raise xxxException(ret)
...........................
我如何从原始异常中提取一些信息,并同时添加我自己的信息?
感谢。
答案 0 :(得分:2)
默认情况下,exception参数存储在message
字段中。
你可以用
data = e.message
如果你愿意,你可以用
改变它e.message['bananas'] = 'custard'