fix: 改善 fudai_detail_validator 异常处理

- 收紧 except 类型为 ValueError/TypeError
- 添加 logging.debug 替代静默 pass,便于排查 OCR 识别错误

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CodexandClaude Opus 4.5 committed 2026-05-20 22:54:44 +08:00
1 parent 68a2ab73ba
commit 6b22939c7e
1 file changed
+9 -5
@@ -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:内容不能为空(至少要有一些文字)
# 如果运行时显式禁用了内容识别,则跳过此检查(允许内容为空)