fix(api): gracefully handle integrity error on inbound record deletion

This commit is contained in:
DXC
2026-03-25 10:48:43 +08:00
parent a8119dd577
commit ac7774e0e3
2 changed files with 8 additions and 1 deletions

View File

@ -309,8 +309,11 @@ def delete_buy(id):
try:
material_name = BuyInboundService.delete_inbound(id)
return jsonify({"code": 200, "msg": "删除成功", "material_name": material_name})
except ValueError as ve:
# 捕获业务拦截的报错,返回友好的 msg
return jsonify({"code": 400, "msg": str(ve)})
except Exception as e:
return jsonify({"code": 500, "msg": str(e)}), 500
return jsonify({"code": 500, "msg": "服务器内部错误,请联系系统管理员"}), 500
# ------------------------------------------------------------------