【发布时间】:2019-07-25 05:20:48
【问题描述】:
所以假设我有一些代码会引发任何类型或错误。我希望我的代码改为引发 AssertionError,但打印出原始消息将与原始错误一起打印。我该怎么做?
(示例)
原始错误: TypeError: '>' 在 'str' 和 'int' 的实例之间不支持
自定义错误:AssertionError: exception = TypeError: '>' not supported between 'str' and 'int'
【问题讨论】:
标签: python python-3.x error-handling