fix(api): expose real 500 error stack trace and fix missing func import

This commit is contained in:
DXC
2026-03-25 10:56:31 +08:00
parent ac7774e0e3
commit 7421ef3231
6 changed files with 20 additions and 3 deletions

View File

@ -313,7 +313,9 @@ def delete_buy(id):
# 捕获业务拦截的报错,返回友好的 msg
return jsonify({"code": 400, "msg": str(ve)})
except Exception as e:
return jsonify({"code": 500, "msg": "服务器内部错误,请联系系统管理员"}), 500
import traceback
traceback.print_exc() # 在控制台打印真实错误堆栈
return jsonify({"code": 500, "msg": f"服务器内部错误详情: {str(e)}"}), 500
# ------------------------------------------------------------------

View File

@ -185,9 +185,12 @@ def delete(id):
try:
material_name = ProductInboundService.delete_inbound(id)
return jsonify({"code": 200, "msg": "删除成功", "material_name": material_name})
except ValueError as ve:
return jsonify({"code": 400, "msg": str(ve)})
except Exception as e:
import traceback
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
return jsonify({"code": 500, "msg": f"服务器内部错误详情: {str(e)}"}), 500
@inbound_product_bp.route('/<int:id>/history', methods=['GET'])
@permission_required('inbound_product')

View File

@ -180,9 +180,12 @@ def delete_semi(id):
try:
material_name = SemiInboundService.delete_inbound(id)
return jsonify({"code": 200, "msg": "删除成功", "material_name": material_name})
except ValueError as ve:
return jsonify({"code": 400, "msg": str(ve)})
except Exception as e:
import traceback
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
return jsonify({"code": 500, "msg": f"服务器内部错误详情: {str(e)}"}), 500
@inbound_semi_bp.route('/<int:id>/history', methods=['GET'])
@permission_required('inbound_semi')