From 6b22939c7e7f0a5512b88bf082f46a4a41ccff77 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 20 May 2026 22:54:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B9=E5=96=84=20fudai=5Fdetail=5Fva?= =?UTF-8?q?lidator=20=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 收紧 except 类型为 ValueError/TypeError - 添加 logging.debug 替代静默 pass,便于排查 OCR 识别错误 Co-Authored-By: Claude Opus 4.5 --- fudai_detail_modules/fudai_detail_validator.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fudai_detail_modules/fudai_detail_validator.py b/fudai_detail_modules/fudai_detail_validator.py index e7a3b15..e26dfaf 100644 --- a/fudai_detail_modules/fudai_detail_validator.py +++ b/fudai_detail_modules/fudai_detail_validator.py @@ -8,6 +8,7 @@ from __future__ import annotations """ from typing import Any, Tuple +import logging import re import os import json @@ -28,15 +29,18 @@ def validate_fudai_detail(detail: Tuple, analyser: Any = None) -> Tuple[bool, st time_text = str(detail[1] or "").strip() try: participants = int(detail[2] or 0) - except Exception: + except (ValueError, TypeError) as e: + logging.debug("参与人数解析失败: %r, 使用默认值0: %s", detail[2], e) participants = 0 try: copies = int(detail[3] or 0) - except Exception: + except (ValueError, TypeError) as e: + logging.debug("份数解析失败: %r, 使用默认值0: %s", detail[3], e) copies = 0 try: prize_value_yuan = float(detail[4] or 0.0) - except Exception: + except (ValueError, TypeError) as e: + logging.debug("奖品金额解析失败: %r, 使用默认值0.0: %s", detail[4], e) prize_value_yuan = 0.0 countdown_tuple = detail[5] @@ -45,8 +49,8 @@ def validate_fudai_detail(detail: Tuple, analyser: Any = None) -> Tuple[bool, st try: countdown_start = float(countdown_tuple[0] or 0.0) countdown_end = float(countdown_tuple[1] or 0.0) - except Exception: - pass + except (ValueError, TypeError) as e: + logging.debug("倒计时元组解析失败: %r: %s", countdown_tuple, e) # 检查1:内容不能为空(至少要有一些文字) # 如果运行时显式禁用了内容识别,则跳过此检查(允许内容为空)