【发布时间】:2017-05-23 14:37:57
【问题描述】:
我想检查我的 python 应用程序中的类型错误。
下面这种方式捕捉ValueError是否正确?
async def find_video_by_id(request):
try:
id = int(request.query['id'])
...
except ValueError:
exception_message = "Incorrect type of video id was specified."
logger.exception(exception_message)
raven_client.captureException(exception_message)
raise ValueError(exception_message)
except Exception as ex:
logger.exception("find_video_by_id")
raven_client.captureException()
raise ex
【问题讨论】:
-
对不起,只是为了理解,为什么在异常中时要引发异常?我在较小的代码上尝试过,但这样做时遇到了问题。
标签: python-3.x exception