In Python, how do I inspect and then re-raise an exception while maintaining the original call stack?

狂风中的少年 提交于 2019-12-01 03:48:39

Just do:

raise

instead of raise e. See the tutorial section on raising exceptions, and also the language reference on raise statements:

If no expressions are present, raise re-raises the last exception that was active in the current scope. If no exception is active in the current scope, a TypeError exception is raised indicating that this is an error (if running under IDLE, a Queue.Empty exception is raised instead).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!