【发布时间】:2021-06-13 07:46:51
【问题描述】:
我是 python 和 django 的新手,现在我正在尝试开发人脸识别 api,但出现错误,这是错误日志:https://gist.github.com/wahyu-handayani/9d8338741ee50697332f7ed63f9769e2
当该错误发生时,服务器将关闭,所以我只想在邮递员中抛出或返回一些东西,以便服务器仍然开启。到目前为止我一直在做try和except
try:
# some codes
cv2.imshow('Frame', image) # here is the code that makes the error happens
except Exception as e:
return JsonResponse({"Error": str(e)})
但仍然......它不会进入Exception 块。如何在函数中为try和except做正确的方法?
【问题讨论】:
标签: python django function error-handling