coze-coding-utils 0.2.1__py3-none-any.whl → 0.2.2a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coze_coding_utils/__init__.py +1 -1
- coze_coding_utils/error/__init__.py +31 -0
- coze_coding_utils/error/classifier.py +320 -0
- coze_coding_utils/error/codes.py +356 -0
- coze_coding_utils/error/exceptions.py +439 -0
- coze_coding_utils/error/patterns.py +939 -0
- coze_coding_utils/error/test_classifier.py +0 -0
- coze_coding_utils/file/__init__.py +0 -0
- coze_coding_utils/file/file.py +327 -0
- coze_coding_utils/helper/__init__.py +0 -0
- coze_coding_utils/helper/agent_helper.py +599 -0
- coze_coding_utils/helper/graph_helper.py +231 -0
- coze_coding_utils/log/__init__.py +0 -0
- coze_coding_utils/log/common.py +8 -0
- coze_coding_utils/log/config.py +10 -0
- coze_coding_utils/log/err_trace.py +88 -0
- coze_coding_utils/log/loop_trace.py +72 -0
- coze_coding_utils/log/node_log.py +487 -0
- coze_coding_utils/log/parser.py +255 -0
- coze_coding_utils/log/write_log.py +183 -0
- coze_coding_utils/messages/__init__.py +0 -0
- coze_coding_utils/messages/client.py +48 -0
- coze_coding_utils/messages/server.py +173 -0
- coze_coding_utils/openai/__init__.py +5 -0
- coze_coding_utils/openai/converter/__init__.py +6 -0
- coze_coding_utils/openai/converter/request_converter.py +165 -0
- coze_coding_utils/openai/converter/response_converter.py +467 -0
- coze_coding_utils/openai/handler.py +298 -0
- coze_coding_utils/openai/types/__init__.py +37 -0
- coze_coding_utils/openai/types/request.py +24 -0
- coze_coding_utils/openai/types/response.py +178 -0
- {coze_coding_utils-0.2.1.dist-info → coze_coding_utils-0.2.2a1.dist-info}/METADATA +2 -2
- coze_coding_utils-0.2.2a1.dist-info/RECORD +37 -0
- coze_coding_utils-0.2.1.dist-info/RECORD +0 -7
- {coze_coding_utils-0.2.1.dist-info → coze_coding_utils-0.2.2a1.dist-info}/WHEEL +0 -0
- {coze_coding_utils-0.2.1.dist-info → coze_coding_utils-0.2.2a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
"""
|
|
2
|
+
错误模式匹配表
|
|
3
|
+
|
|
4
|
+
统一管理所有错误关键词到错误码的映射,避免在多个函数中重复定义匹配逻辑。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import List, Tuple, Optional
|
|
8
|
+
from .codes import ErrorCode
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ErrorPattern = Tuple[List[str], int, str]
|
|
12
|
+
|
|
13
|
+
ERROR_PATTERNS: List[ErrorPattern] = [
|
|
14
|
+
# ==================== 最高优先级模式 (防止误分类) ====================
|
|
15
|
+
# 视频生成任务创建失败 - 优先于下载失败
|
|
16
|
+
(['视频生成任务创建失败', '404 client error'],
|
|
17
|
+
ErrorCode.API_VIDEO_GEN_NOT_FOUND, "视频生成端点404"),
|
|
18
|
+
(['视频生成任务创建失败', '401 client error'],
|
|
19
|
+
ErrorCode.API_LLM_AUTH_FAILED, "视频生成认证失败"),
|
|
20
|
+
(['视频生成任务创建失败'],
|
|
21
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成任务创建失败"),
|
|
22
|
+
|
|
23
|
+
# 飞书API错误 - 优先于下载失败
|
|
24
|
+
(['飞书api错误', 'fieldnamenotfound'],
|
|
25
|
+
ErrorCode.INTEGRATION_FEISHU_API_FAILED, "飞书字段不存在"),
|
|
26
|
+
(['同步到飞书失败', '飞书api错误'],
|
|
27
|
+
ErrorCode.INTEGRATION_FEISHU_API_FAILED, "飞书同步失败"),
|
|
28
|
+
|
|
29
|
+
# model not found - 优先于通用 API 错误
|
|
30
|
+
(['not found model', 'model not found'],
|
|
31
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "模型未找到"),
|
|
32
|
+
|
|
33
|
+
# InvalidUpdateError - 优先于业务节点失败
|
|
34
|
+
(['invalidupdateerror', 'expected dict'],
|
|
35
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "节点返回类型错误"),
|
|
36
|
+
(['invalidupdateerror', 'can receive only one value'],
|
|
37
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "节点返回值冲突"),
|
|
38
|
+
|
|
39
|
+
# ==================== 代码执行超时 (高优先级) ====================
|
|
40
|
+
(['代码执行超时'],
|
|
41
|
+
ErrorCode.RUNTIME_TIMEOUT, "代码执行超时"),
|
|
42
|
+
(['execution timeout', 'exceeded 900 seconds'],
|
|
43
|
+
ErrorCode.RUNTIME_TIMEOUT, "执行超时"),
|
|
44
|
+
(['代码服务器协议错误', '服务可能在处理请求时崩溃'],
|
|
45
|
+
ErrorCode.API_NETWORK_REMOTE_PROTOCOL, "代码服务器协议错误"),
|
|
46
|
+
|
|
47
|
+
# ==================== 模块导入错误 (高优先级) ====================
|
|
48
|
+
(['no module named'],
|
|
49
|
+
ErrorCode.CODE_NAME_IMPORT_ERROR, "模块未找到"),
|
|
50
|
+
(['cannot import name'],
|
|
51
|
+
ErrorCode.CODE_NAME_IMPORT_ERROR, "无法导入名称"),
|
|
52
|
+
(['is not installed', 'pip install'],
|
|
53
|
+
ErrorCode.CONFIG_ENV_MISSING, "依赖库未安装"),
|
|
54
|
+
|
|
55
|
+
# ==================== JSON/语法错误 (高优先级) ====================
|
|
56
|
+
(['invalid control character'],
|
|
57
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON包含非法控制字符"),
|
|
58
|
+
(["expecting ',' delimiter", "expecting ','"],
|
|
59
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON格式错误"),
|
|
60
|
+
(['positional argument follows keyword argument'],
|
|
61
|
+
ErrorCode.CODE_SYNTAX_INVALID, "语法错误:位置参数在关键字参数之后"),
|
|
62
|
+
(['parameter without a default follows parameter with a default'],
|
|
63
|
+
ErrorCode.CODE_SYNTAX_INVALID, "语法错误:无默认值参数在有默认值参数之后"),
|
|
64
|
+
|
|
65
|
+
# ==================== LLM 特定错误 (高优先级) ====================
|
|
66
|
+
(['unsupported thinking type'],
|
|
67
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "不支持的思考模式"),
|
|
68
|
+
(['invalid tool_call_id', 'no matching tool call'],
|
|
69
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "无效的工具调用ID"),
|
|
70
|
+
(['apiconnectionerror', 'connection error'],
|
|
71
|
+
ErrorCode.API_NETWORK_CONNECTION, "API连接错误"),
|
|
72
|
+
(['api_key client option must be set', 'api_key is required'],
|
|
73
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "API Key未配置"),
|
|
74
|
+
|
|
75
|
+
# ==================== 语法/缩进错误 (高优先级) ====================
|
|
76
|
+
(['unexpected indent', 'indentationerror'],
|
|
77
|
+
ErrorCode.CODE_SYNTAX_INDENTATION, "缩进错误"),
|
|
78
|
+
(['unterminated string literal', 'unterminated triple-quoted'],
|
|
79
|
+
ErrorCode.CODE_SYNTAX_INVALID, "字符串未终止"),
|
|
80
|
+
(['syntaxerror:', 'invalid syntax'],
|
|
81
|
+
ErrorCode.CODE_SYNTAX_INVALID, "语法错误"),
|
|
82
|
+
(['relative import beyond top-level', 'attempted relative import'],
|
|
83
|
+
ErrorCode.CODE_NAME_IMPORT_ERROR, "相对导入错误"),
|
|
84
|
+
|
|
85
|
+
# ==================== 环境/配置错误 (高优先级) ====================
|
|
86
|
+
(['display', 'no display name'],
|
|
87
|
+
ErrorCode.CONFIG_ENV_MISSING, "DISPLAY环境变量未设置"),
|
|
88
|
+
(['portaudio library not found', 'portaudio'],
|
|
89
|
+
ErrorCode.CONFIG_ENV_MISSING, "PortAudio库未安装"),
|
|
90
|
+
(['功能未实现'],
|
|
91
|
+
ErrorCode.RUNTIME_ASYNC_NOT_IMPL, "功能未实现"),
|
|
92
|
+
(['poppler', 'is poppler installed'],
|
|
93
|
+
ErrorCode.CONFIG_ENV_MISSING, "Poppler未安装"),
|
|
94
|
+
(['paddleocr', 'ocr模型未初始化'],
|
|
95
|
+
ErrorCode.CONFIG_ENV_MISSING, "PaddleOCR未初始化"),
|
|
96
|
+
|
|
97
|
+
# ==================== LangGraph 错误 (高优先级) ====================
|
|
98
|
+
(['invalid_graph_node', 'unknown node'],
|
|
99
|
+
ErrorCode.BUSINESS_GRAPH_INVALID, "LangGraph节点无效"),
|
|
100
|
+
(['invalid_concurrent', 'langgraph/errors'],
|
|
101
|
+
ErrorCode.BUSINESS_GRAPH_INVALID, "LangGraph并发错误"),
|
|
102
|
+
(['edge starting at unknown node', 'unknown target'],
|
|
103
|
+
ErrorCode.BUSINESS_GRAPH_INVALID, "LangGraph边定义错误"),
|
|
104
|
+
|
|
105
|
+
# ==================== 业务数据错误 (高优先级) ====================
|
|
106
|
+
(['应用启动失败', '未捕获到具体错误'],
|
|
107
|
+
ErrorCode.RUNTIME_EXECUTION_FAILED, "应用启动失败"),
|
|
108
|
+
(['请求失败:'],
|
|
109
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "请求失败"),
|
|
110
|
+
(['size of the input image', 'exceeds the limit'],
|
|
111
|
+
ErrorCode.RESOURCE_FILE_TOO_LARGE, "图片大小超限"),
|
|
112
|
+
(['headobject operation', 'not found'],
|
|
113
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "S3对象不存在"),
|
|
114
|
+
|
|
115
|
+
# ==================== OCR/文档处理错误 ====================
|
|
116
|
+
(['ocr识别失败', '无法从响应中提取有效的json'],
|
|
117
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "OCR识别失败"),
|
|
118
|
+
(['文件读取失败', '找不到文件'],
|
|
119
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "文件读取失败"),
|
|
120
|
+
(['excel file format cannot be determined', 'specify an engine'],
|
|
121
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "Excel格式无法识别"),
|
|
122
|
+
(['file contains no valid workbook', 'workbook part'],
|
|
123
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "Excel文件无效"),
|
|
124
|
+
(['pdf内容提取失败', 'pdf读取失败'],
|
|
125
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "PDF读取失败"),
|
|
126
|
+
(['txt转csv失败', '没有生成有效数据'],
|
|
127
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "TXT转换失败"),
|
|
128
|
+
(['无法读取图片', '尝试修复文件失败'],
|
|
129
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片读取失败"),
|
|
130
|
+
(['未能提取到有效的数值数据', '识别图片表格失败'],
|
|
131
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "数据提取失败"),
|
|
132
|
+
|
|
133
|
+
# ==================== 邮件/网络服务错误 ====================
|
|
134
|
+
(['邮箱连接失败', 'gaierror', 'name or service not known'],
|
|
135
|
+
ErrorCode.API_NETWORK_CONNECTION, "邮箱连接失败"),
|
|
136
|
+
(['wl-paste', 'xclip', '剪贴板'],
|
|
137
|
+
ErrorCode.CONFIG_ENV_MISSING, "剪贴板工具缺失"),
|
|
138
|
+
(['无头环境', '没有图形界面', '无法访问剪贴板'],
|
|
139
|
+
ErrorCode.CONFIG_ENV_MISSING, "无图形界面环境"),
|
|
140
|
+
|
|
141
|
+
# ==================== 视频/音频生成错误 ====================
|
|
142
|
+
(['火山方舟api认证失败', '图片生成视频失败'],
|
|
143
|
+
ErrorCode.API_LLM_AUTH_FAILED, "火山方舟认证失败"),
|
|
144
|
+
(['视频生成服务端点不可用', '404错误'],
|
|
145
|
+
ErrorCode.API_VIDEO_GEN_NOT_FOUND, "视频生成端点404"),
|
|
146
|
+
(['没有音频可以合成视频', '标题和正文内容为空'],
|
|
147
|
+
ErrorCode.VALIDATION_INPUT_EMPTY, "音频内容为空"),
|
|
148
|
+
(['no images generated', 'cannot create video'],
|
|
149
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "无图片生成视频"),
|
|
150
|
+
(['没有成功生成临时视频文件', '没有成功生成任何视频片段'],
|
|
151
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "视频片段生成失败"),
|
|
152
|
+
(['生成的文案包含违规词', '平台规则'],
|
|
153
|
+
ErrorCode.API_LLM_CONTENT_FILTER, "内容违规"),
|
|
154
|
+
(['期望生成.*张图片', '实际生成'],
|
|
155
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片生成数量不足"),
|
|
156
|
+
(['没有可用的图片url', '图片生成节点'],
|
|
157
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片URL缺失"),
|
|
158
|
+
|
|
159
|
+
# ==================== API 错误补充 ====================
|
|
160
|
+
(['openai.notfounderror', 'error code: 404'],
|
|
161
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "OpenAI资源未找到"),
|
|
162
|
+
(['openai.internalservererror', 'error code: 500'],
|
|
163
|
+
ErrorCode.API_LLM_REQUEST_FAILED, "OpenAI服务器错误"),
|
|
164
|
+
(['botocore.exceptions', 'invalidargument', 'putobject'],
|
|
165
|
+
ErrorCode.RESOURCE_S3_UPLOAD_FAILED, "S3上传参数无效"),
|
|
166
|
+
(['表格不存在或访问权限不足'],
|
|
167
|
+
ErrorCode.INTEGRATION_CREDENTIAL_INVALID, "表格访问权限不足"),
|
|
168
|
+
(['invalid appid', 'access_token 失败'],
|
|
169
|
+
ErrorCode.INTEGRATION_CREDENTIAL_INVALID, "AppID无效"),
|
|
170
|
+
|
|
171
|
+
# ==================== 编码错误 (高优先级) ====================
|
|
172
|
+
(["codec can't encode", 'surrogates not allowed'],
|
|
173
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "字符编码错误"),
|
|
174
|
+
(['xml compatible', 'null bytes or control characters'],
|
|
175
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "XML兼容性错误"),
|
|
176
|
+
|
|
177
|
+
# ==================== 类型错误补充 ====================
|
|
178
|
+
(['has no len()'],
|
|
179
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "对象不支持len操作"),
|
|
180
|
+
(['list index out of range'],
|
|
181
|
+
ErrorCode.CODE_INDEX_OUT_OF_RANGE, "列表索引越界"),
|
|
182
|
+
(["invalid literal for int()", "with base 10"],
|
|
183
|
+
ErrorCode.VALIDATION_FIELD_TYPE, "整数解析错误"),
|
|
184
|
+
|
|
185
|
+
# ==================== HTTP 请求错误 ====================
|
|
186
|
+
(['执行请求时发生未知错误', '404:', 'error from'],
|
|
187
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP请求错误"),
|
|
188
|
+
(['执行请求时发生未知错误', '401:'],
|
|
189
|
+
ErrorCode.API_LLM_AUTH_FAILED, "认证失败"),
|
|
190
|
+
|
|
191
|
+
# ==================== URL/文件名验证错误 ====================
|
|
192
|
+
(['no scheme supplied', "invalid url ''"],
|
|
193
|
+
ErrorCode.API_NETWORK_URL_INVALID, "URL格式无效"),
|
|
194
|
+
(['file name invalid', 's3 对象命名规范'],
|
|
195
|
+
ErrorCode.VALIDATION_INPUT_INVALID, "文件名格式无效"),
|
|
196
|
+
|
|
197
|
+
# ==================== 图片格式错误 ====================
|
|
198
|
+
(['image format is not supported'],
|
|
199
|
+
ErrorCode.API_LLM_IMAGE_FORMAT, "图片格式不支持"),
|
|
200
|
+
|
|
201
|
+
# ==================== 视频/图片处理错误 (需要精确匹配) ====================
|
|
202
|
+
(['视频处理失败', '视频解析失败', '视频转换失败'],
|
|
203
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "视频处理错误"),
|
|
204
|
+
(['图片处理失败', '图片解析失败', '图片转换失败'],
|
|
205
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片处理错误"),
|
|
206
|
+
(['invalid image', 'image is invalid', 'cannot identify image'],
|
|
207
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片格式无效"),
|
|
208
|
+
(['video codec', 'video format', 'unsupported video'],
|
|
209
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "视频格式错误"),
|
|
210
|
+
(['图片生成节点错误', '图片生成失败'],
|
|
211
|
+
ErrorCode.API_IMAGE_GEN_FAILED, "图片生成失败"),
|
|
212
|
+
(['加载图像失败', '加载头部图像失败'],
|
|
213
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图像加载失败"),
|
|
214
|
+
(['图像预处理失败', 'magic number'],
|
|
215
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "图像格式无效"),
|
|
216
|
+
|
|
217
|
+
# ==================== 音频处理错误 ====================
|
|
218
|
+
(['语音识别失败', 'asr 识别失败', 'asr识别失败'],
|
|
219
|
+
ErrorCode.API_AUDIO_TRANSCRIBE_FAILED, "语音识别失败"),
|
|
220
|
+
(['音频生成失败', '所有分段均未成功生成'],
|
|
221
|
+
ErrorCode.API_AUDIO_GEN_FAILED, "音频生成失败"),
|
|
222
|
+
(['bgm添加失败', 'audio_bitrate'],
|
|
223
|
+
ErrorCode.RESOURCE_AUDIO_PROCESS_FAILED, "BGM添加失败"),
|
|
224
|
+
|
|
225
|
+
# ==================== 网络请求失败 (业务层) ====================
|
|
226
|
+
(['网络请求失败', '400 client error'],
|
|
227
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP 400错误"),
|
|
228
|
+
(['网络请求失败', '404 client error'],
|
|
229
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP 404错误"),
|
|
230
|
+
(['http 错误', 'bad request'],
|
|
231
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP请求错误"),
|
|
232
|
+
(['http请求失败', '状态码'],
|
|
233
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP请求失败"),
|
|
234
|
+
|
|
235
|
+
# ==================== 业务节点失败细分 ====================
|
|
236
|
+
(['expected dict, got', 'invalidupdateerror'],
|
|
237
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "节点返回类型错误"),
|
|
238
|
+
(['爬取.*失败', '爬取抖音'],
|
|
239
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "爬虫服务失败"),
|
|
240
|
+
(['获取邮件失败', 'login fail', 'account is abnormal'],
|
|
241
|
+
ErrorCode.INTEGRATION_CREDENTIAL_INVALID, "邮件登录失败"),
|
|
242
|
+
(['标题改写失败', 'expecting value'],
|
|
243
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON解析失败"),
|
|
244
|
+
(['调用.*api.*失败', 'openrouter api'],
|
|
245
|
+
ErrorCode.API_LLM_REQUEST_FAILED, "API调用失败"),
|
|
246
|
+
(['获取股票数据失败', '数据为空'],
|
|
247
|
+
ErrorCode.BUSINESS_DATA_NOT_FOUND, "数据获取失败"),
|
|
248
|
+
(['failed to generate any frames', 'generate any frames'],
|
|
249
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "视频帧生成失败"),
|
|
250
|
+
(['下载视频文件失败', 'file name too long'],
|
|
251
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "文件名过长"),
|
|
252
|
+
(['moviepy', 'imagesequenceclip', 'all images to have the same size'],
|
|
253
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "MoviePy图像尺寸不一致"),
|
|
254
|
+
(['service /root/.wdm', 'chromedriver'],
|
|
255
|
+
ErrorCode.CONFIG_WEBDRIVER_FAILED, "ChromeDriver启动失败"),
|
|
256
|
+
(['视频抽帧失败', 'http 403', '签名可能已过期'],
|
|
257
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "视频抽帧失败"),
|
|
258
|
+
(['所有视频生成端点都尝试失败', '所有视频生成任务均失败'],
|
|
259
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成端点失败"),
|
|
260
|
+
(['上传pdf失败', 'unable to locate credentials'],
|
|
261
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "AWS凭证缺失"),
|
|
262
|
+
(['生成pdf报告失败', 'stylesheet'],
|
|
263
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "PDF样式错误"),
|
|
264
|
+
(['从数据库查询', '失败'],
|
|
265
|
+
ErrorCode.INTEGRATION_DB_QUERY, "数据库查询失败"),
|
|
266
|
+
(['excel文件解析', '表格结构检测失败'],
|
|
267
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "Excel解析失败"),
|
|
268
|
+
(['文档生成失败'],
|
|
269
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "文档生成失败"),
|
|
270
|
+
(['读取.*对照表失败', '读取远程文件失败'],
|
|
271
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "远程文件读取失败"),
|
|
272
|
+
(['工资验证失败', '工资计算失败', '计算工资失败'],
|
|
273
|
+
ErrorCode.BUSINESS_RULE_VIOLATED, "工资处理失败"),
|
|
274
|
+
(['unsupported format string', 'undefined.__fo'],
|
|
275
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "格式化字符串错误"),
|
|
276
|
+
|
|
277
|
+
# ==================== 微信集成错误 ====================
|
|
278
|
+
(['微信公众号', '凭证获取失败'],
|
|
279
|
+
ErrorCode.INTEGRATION_WECHAT_API_FAILED, "微信公众号凭证获取失败"),
|
|
280
|
+
|
|
281
|
+
# ==================== 视频生成任务错误 ====================
|
|
282
|
+
(['视频生成任务创建失败'],
|
|
283
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成任务创建失败"),
|
|
284
|
+
|
|
285
|
+
# ==================== 数据库相关错误 ====================
|
|
286
|
+
(['adminshutdown', 'terminating connection due to administrator command'],
|
|
287
|
+
ErrorCode.INTEGRATION_DB_ADMIN_SHUTDOWN, "数据库连接被管理员关闭"),
|
|
288
|
+
(['ssl connection has been closed unexpectedly'],
|
|
289
|
+
ErrorCode.INTEGRATION_DB_SSL_CLOSED, "数据库SSL连接意外关闭"),
|
|
290
|
+
(['pooltimeout', "couldn't get a connection"],
|
|
291
|
+
ErrorCode.INTEGRATION_DB_POOL_TIMEOUT, "数据库连接池超时"),
|
|
292
|
+
(['the connection is closed'],
|
|
293
|
+
ErrorCode.INTEGRATION_DB_CONNECTION, "数据库连接已关闭"),
|
|
294
|
+
(['psycopg2', 'postgresql'],
|
|
295
|
+
ErrorCode.INTEGRATION_DB_QUERY, "数据库错误"),
|
|
296
|
+
|
|
297
|
+
# ==================== 网络相关错误 ====================
|
|
298
|
+
(['broken pipe', 'errno 32'],
|
|
299
|
+
ErrorCode.API_NETWORK_BROKEN_PIPE, "网络管道断开"),
|
|
300
|
+
(['remoteprotocolerror'],
|
|
301
|
+
ErrorCode.API_NETWORK_REMOTE_PROTOCOL, "远程协议错误"),
|
|
302
|
+
(['error while downloading'],
|
|
303
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "文件下载失败"),
|
|
304
|
+
(['nosuchkey', 'specified key does not exist'],
|
|
305
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "S3对象不存在"),
|
|
306
|
+
(['max retries exceeded', 'connectionpool'],
|
|
307
|
+
ErrorCode.API_NETWORK_CONNECTION, "网络连接失败"),
|
|
308
|
+
(['server error', '500 internal server error'],
|
|
309
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "服务器500错误"),
|
|
310
|
+
|
|
311
|
+
# ==================== Pydantic/验证相关错误 ====================
|
|
312
|
+
(['validation error for chatgenerationchunk', 'basemessagechunk'],
|
|
313
|
+
ErrorCode.VALIDATION_FIELD_TYPE, "LangChain消息类型错误"),
|
|
314
|
+
(['paragraph text', '<para>'],
|
|
315
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "文档段落格式错误"),
|
|
316
|
+
(['pydanticinvalidforjsonschema', 'cannot generate a jsonschema'],
|
|
317
|
+
ErrorCode.VALIDATION_PYDANTIC_SCHEMA, "Pydantic JSON Schema生成失败"),
|
|
318
|
+
(['unable to generate pydantic-core schema'],
|
|
319
|
+
ErrorCode.VALIDATION_PYDANTIC_SCHEMA, "Pydantic Schema生成失败"),
|
|
320
|
+
(['model-field-overridden'],
|
|
321
|
+
ErrorCode.VALIDATION_PYDANTIC_SCHEMA, "Pydantic字段覆盖错误"),
|
|
322
|
+
|
|
323
|
+
# ==================== 正则表达式错误 ====================
|
|
324
|
+
(['bad escape'],
|
|
325
|
+
ErrorCode.CODE_SYNTAX_REGEX_ESCAPE, "正则表达式转义错误"),
|
|
326
|
+
|
|
327
|
+
# ==================== 浏览器/WebDriver 错误 ====================
|
|
328
|
+
(['webdriverexception'],
|
|
329
|
+
ErrorCode.CONFIG_WEBDRIVER_FAILED, "WebDriver启动失败"),
|
|
330
|
+
(["executable doesn't exist", 'browsertype.launch'],
|
|
331
|
+
ErrorCode.CONFIG_BROWSER_NOT_FOUND, "浏览器可执行文件不存在"),
|
|
332
|
+
(['chrome failed to start'],
|
|
333
|
+
ErrorCode.CONFIG_WEBDRIVER_FAILED, "Chrome启动失败"),
|
|
334
|
+
(['unable to obtain driver'],
|
|
335
|
+
ErrorCode.CONFIG_WEBDRIVER_FAILED, "无法获取WebDriver"),
|
|
336
|
+
|
|
337
|
+
# ==================== 视频相关错误 ====================
|
|
338
|
+
(['视频文件不存在'],
|
|
339
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "视频文件不存在"),
|
|
340
|
+
(['剪映草稿文件不存在'],
|
|
341
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "剪映草稿文件不存在"),
|
|
342
|
+
(['视频片段生成失败', '所有视频片段生成失败'],
|
|
343
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "视频片段生成失败"),
|
|
344
|
+
(['没有生成任何视频片段', '未能成功生成任何视频片段', '没有可用的视频片段'],
|
|
345
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "无可用视频片段"),
|
|
346
|
+
(['下载视频失败', '视频下载失败'],
|
|
347
|
+
ErrorCode.RESOURCE_VIDEO_DOWNLOAD_FAILED, "视频下载失败"),
|
|
348
|
+
(['视频预处理失败'],
|
|
349
|
+
ErrorCode.RESOURCE_FFMPEG_FAILED, "视频预处理失败"),
|
|
350
|
+
(['ffmpeg'],
|
|
351
|
+
ErrorCode.RESOURCE_FFMPEG_FAILED, "FFmpeg处理失败"),
|
|
352
|
+
|
|
353
|
+
# ==================== 图片相关错误 ====================
|
|
354
|
+
(['无法下载图片', '下载图片失败'],
|
|
355
|
+
ErrorCode.RESOURCE_IMAGE_DOWNLOAD_FAILED, "图片下载失败"),
|
|
356
|
+
(['图片url列表为空'],
|
|
357
|
+
ErrorCode.VALIDATION_INPUT_EMPTY, "图片URL列表为空"),
|
|
358
|
+
(['所有图片都无法访问'],
|
|
359
|
+
ErrorCode.RESOURCE_IMAGE_DOWNLOAD_FAILED, "图片无法访问"),
|
|
360
|
+
(['输入的图片url无法访问'],
|
|
361
|
+
ErrorCode.RESOURCE_IMAGE_DOWNLOAD_FAILED, "图片URL无法访问"),
|
|
362
|
+
|
|
363
|
+
# ==================== TTS 相关错误 ====================
|
|
364
|
+
(['腾讯云 tts', '腾讯云tts'],
|
|
365
|
+
ErrorCode.API_AUDIO_GEN_FAILED, "腾讯云TTS生成失败"),
|
|
366
|
+
|
|
367
|
+
# ==================== 飞书相关错误 ====================
|
|
368
|
+
(['获取草稿列表失败'],
|
|
369
|
+
ErrorCode.INTEGRATION_FEISHU_API_FAILED, "飞书获取草稿列表失败"),
|
|
370
|
+
(['飞书api错误'],
|
|
371
|
+
ErrorCode.INTEGRATION_FEISHU_API_FAILED, "飞书API错误"),
|
|
372
|
+
(['feishu api', 'feishu error'],
|
|
373
|
+
ErrorCode.INTEGRATION_FEISHU_API_FAILED, "飞书API错误"),
|
|
374
|
+
|
|
375
|
+
# ==================== Webhook 错误 ====================
|
|
376
|
+
(['获取webhook密钥失败'],
|
|
377
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "Webhook密钥获取失败"),
|
|
378
|
+
|
|
379
|
+
# ==================== LLM/API 相关错误 ====================
|
|
380
|
+
(['total tokens', 'exceed max'],
|
|
381
|
+
ErrorCode.API_LLM_TOKEN_LIMIT, "Token总数超限"),
|
|
382
|
+
(['input length', 'exceeds the maximum'],
|
|
383
|
+
ErrorCode.API_LLM_TOKEN_LIMIT, "输入长度超限"),
|
|
384
|
+
(['context_length_exceeded', 'maximum context length'],
|
|
385
|
+
ErrorCode.API_LLM_TOKEN_LIMIT, "上下文长度超限"),
|
|
386
|
+
(['llm model received multi-modal messages'],
|
|
387
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "LLM不支持多模态消息"),
|
|
388
|
+
(['invalid messages'],
|
|
389
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "消息格式无效"),
|
|
390
|
+
(['modelnotopen', 'has not activated the model'],
|
|
391
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "模型未开通"),
|
|
392
|
+
(['model not found'],
|
|
393
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "模型未找到"),
|
|
394
|
+
(['资源点不足', 'errbalanceoverdue'],
|
|
395
|
+
ErrorCode.BUSINESS_QUOTA_INSUFFICIENT, "资源点不足"),
|
|
396
|
+
(['errtoomanyrequest', '触发限流', 'rate limit'],
|
|
397
|
+
ErrorCode.API_LLM_RATE_LIMIT, "请求频率限制"),
|
|
398
|
+
|
|
399
|
+
# ==================== 递归限制错误 ====================
|
|
400
|
+
(['recursion limit', 'graph_recursion_limit'],
|
|
401
|
+
ErrorCode.RUNTIME_RECURSION_LIMIT, "递归深度超限"),
|
|
402
|
+
|
|
403
|
+
# ==================== 类型/代码错误 ====================
|
|
404
|
+
(['structuredtool', 'not callable'],
|
|
405
|
+
ErrorCode.CODE_TYPE_NOT_CALLABLE, "StructuredTool对象不可调用"),
|
|
406
|
+
(['object is not callable'],
|
|
407
|
+
ErrorCode.CODE_TYPE_NOT_CALLABLE, "对象不可调用"),
|
|
408
|
+
(['zerodivisionerror', 'division by zero'],
|
|
409
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "除零错误"),
|
|
410
|
+
(['unicodedecodeerror', 'unicodeencodeerror'],
|
|
411
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "编码错误"),
|
|
412
|
+
(['too many values to unpack', 'not enough values to unpack'],
|
|
413
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "解包错误"),
|
|
414
|
+
(['is not defined'],
|
|
415
|
+
ErrorCode.CODE_NAME_NOT_DEFINED, "变量未定义"),
|
|
416
|
+
(['cannot access local variable'],
|
|
417
|
+
ErrorCode.CODE_NAME_NOT_DEFINED, "局部变量未定义"),
|
|
418
|
+
(['got an unexpected keyword argument'],
|
|
419
|
+
ErrorCode.CODE_TYPE_EXTRA_ARG, "函数参数错误"),
|
|
420
|
+
(["can't compare offset-naive and offset-aware datetimes"],
|
|
421
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "时区类型不兼容"),
|
|
422
|
+
|
|
423
|
+
# ==================== AttributeError 模式 ====================
|
|
424
|
+
(["'str' object has no attribute"],
|
|
425
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "字符串类型错误"),
|
|
426
|
+
(["'nonetype' object has no attribute"],
|
|
427
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "对象为None"),
|
|
428
|
+
(["'dict' object has no attribute"],
|
|
429
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "字典类型错误"),
|
|
430
|
+
(["'list' object has no attribute"],
|
|
431
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "列表类型错误"),
|
|
432
|
+
(['model_dump'],
|
|
433
|
+
ErrorCode.CODE_ATTR_MODEL_DUMP, "对象类型错误"),
|
|
434
|
+
(['object has no attribute'],
|
|
435
|
+
ErrorCode.CODE_ATTR_NOT_FOUND, "属性不存在"),
|
|
436
|
+
|
|
437
|
+
# ==================== 集成服务错误 ====================
|
|
438
|
+
(['integration not found', 'code=190000006'],
|
|
439
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "集成服务未找到"),
|
|
440
|
+
(['integration credential failed', 'credential request failed'],
|
|
441
|
+
ErrorCode.INTEGRATION_CREDENTIAL_INVALID, "集成凭证请求失败"),
|
|
442
|
+
(['imap连接失败', 'imap error', 'imap失败'],
|
|
443
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "邮件连接失败"),
|
|
444
|
+
(['邮件发送失败', '邮件连接失败', '邮件操作失败'],
|
|
445
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "邮件操作失败"),
|
|
446
|
+
|
|
447
|
+
# ==================== 文件相关错误 ====================
|
|
448
|
+
(['读取excel失败'],
|
|
449
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "Excel读取失败"),
|
|
450
|
+
(['解压文件失败', '解压失败'],
|
|
451
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "解压文件失败"),
|
|
452
|
+
(['openpyxl does not support'],
|
|
453
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "Excel格式不支持"),
|
|
454
|
+
(['文件不存在', 'file not found', 'not exist'],
|
|
455
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "文件不存在"),
|
|
456
|
+
|
|
457
|
+
# ==================== URL 相关错误 ====================
|
|
458
|
+
(['url不支持直接使用', '临时签名url'],
|
|
459
|
+
ErrorCode.API_NETWORK_URL_INVALID, "临时签名URL不支持"),
|
|
460
|
+
(['链接已过期', 'url已过期'],
|
|
461
|
+
ErrorCode.API_NETWORK_URL_INVALID, "链接已过期"),
|
|
462
|
+
|
|
463
|
+
# ==================== 输入验证错误 ====================
|
|
464
|
+
(['输入验证失败'],
|
|
465
|
+
ErrorCode.VALIDATION_INPUT_INVALID, "输入验证失败"),
|
|
466
|
+
(['没有有效的', '可供处理'],
|
|
467
|
+
ErrorCode.VALIDATION_INPUT_EMPTY, "无有效输入"),
|
|
468
|
+
(['未找到任何对话内容'],
|
|
469
|
+
ErrorCode.VALIDATION_INPUT_EMPTY, "内容为空"),
|
|
470
|
+
|
|
471
|
+
# ==================== 业务数据错误 ====================
|
|
472
|
+
(['无法从搜索结果中提取'],
|
|
473
|
+
ErrorCode.BUSINESS_DATA_NOT_FOUND, "数据提取失败"),
|
|
474
|
+
(['未识别到', '无法识别'],
|
|
475
|
+
ErrorCode.BUSINESS_DATA_NOT_FOUND, "识别失败"),
|
|
476
|
+
(['最大搜索调用次数限制'],
|
|
477
|
+
ErrorCode.BUSINESS_QUOTA_EXCEEDED, "搜索调用次数超限"),
|
|
478
|
+
|
|
479
|
+
# ==================== 抖音相关错误 ====================
|
|
480
|
+
(['抖音需要登录', 'douyin', 'cookie'],
|
|
481
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "抖音需要登录cookies"),
|
|
482
|
+
(['解析抖音链接失败', '无法从抖音'],
|
|
483
|
+
ErrorCode.BUSINESS_DATA_NOT_FOUND, "抖音链接解析失败"),
|
|
484
|
+
|
|
485
|
+
# ==================== 通用失败模式 (优先级较低,放在最后) ====================
|
|
486
|
+
(['抓取页面失败', '爬取失败', '页面抓取失败'],
|
|
487
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "页面抓取失败"),
|
|
488
|
+
(['大模型调用失败', 'llm调用失败', 'llm connection failed'],
|
|
489
|
+
ErrorCode.API_NETWORK_CONNECTION, "大模型调用连接失败"),
|
|
490
|
+
(['测试异常'],
|
|
491
|
+
ErrorCode.RUNTIME_EXECUTION_FAILED, "测试异常"),
|
|
492
|
+
|
|
493
|
+
# ==================== 剩余 900002 错误模式补充 ====================
|
|
494
|
+
# 键不存在 (中文前缀)
|
|
495
|
+
(['键不存在'],
|
|
496
|
+
ErrorCode.CODE_KEY_NOT_FOUND, "键不存在"),
|
|
497
|
+
|
|
498
|
+
# 类型错误 (中文前缀)
|
|
499
|
+
(['类型错误', 'unsupported operand type'],
|
|
500
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "类型错误"),
|
|
501
|
+
|
|
502
|
+
# 缺少必需参数 (中文前缀)
|
|
503
|
+
(['缺少必需参数'],
|
|
504
|
+
ErrorCode.CODE_TYPE_MISSING_ARG, "缺少必需参数"),
|
|
505
|
+
|
|
506
|
+
# bash 脚本错误
|
|
507
|
+
(['bash:', 'no such file or directory', '进程退出码'],
|
|
508
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "bash脚本文件不存在"),
|
|
509
|
+
|
|
510
|
+
# 值错误 (中文前缀)
|
|
511
|
+
(['值错误', 'time data', 'does not match format'],
|
|
512
|
+
ErrorCode.VALIDATION_FIELD_VALUE, "时间格式错误"),
|
|
513
|
+
(['值错误'],
|
|
514
|
+
ErrorCode.VALIDATION_FIELD_VALUE, "值错误"),
|
|
515
|
+
|
|
516
|
+
# 视频生成过程出错
|
|
517
|
+
(['视频生成过程出错', '403 client error'],
|
|
518
|
+
ErrorCode.API_LLM_AUTH_FAILED, "视频生成认证失败"),
|
|
519
|
+
(['视频生成过程出错'],
|
|
520
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成过程出错"),
|
|
521
|
+
|
|
522
|
+
# 运行时错误 (中文前缀)
|
|
523
|
+
(['运行时错误', 'no current event loop'],
|
|
524
|
+
ErrorCode.RUNTIME_THREAD_ERROR, "事件循环错误"),
|
|
525
|
+
(['运行时错误'],
|
|
526
|
+
ErrorCode.RUNTIME_EXECUTION_FAILED, "运行时错误"),
|
|
527
|
+
|
|
528
|
+
# 视频生成失败 (中文前缀)
|
|
529
|
+
(['视频生成失败', '403 client error'],
|
|
530
|
+
ErrorCode.API_LLM_AUTH_FAILED, "视频生成认证失败"),
|
|
531
|
+
(['视频生成失败', 'timeout'],
|
|
532
|
+
ErrorCode.RUNTIME_TIMEOUT, "视频生成超时"),
|
|
533
|
+
(['视频生成失败', 'no such file'],
|
|
534
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "视频生成文件不存在"),
|
|
535
|
+
(['视频生成失败'],
|
|
536
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成失败"),
|
|
537
|
+
|
|
538
|
+
# 视频生成服务不可用
|
|
539
|
+
(['视频生成服务不可用', '404'],
|
|
540
|
+
ErrorCode.API_VIDEO_GEN_NOT_FOUND, "视频生成服务404"),
|
|
541
|
+
(['视频生成服务不可用'],
|
|
542
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成服务不可用"),
|
|
543
|
+
|
|
544
|
+
# ChatGeneration 类型错误
|
|
545
|
+
(['unsupported operand type', 'chatgeneration'],
|
|
546
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "LangChain类型错误"),
|
|
547
|
+
|
|
548
|
+
# Function docstring 错误
|
|
549
|
+
(['function must have a docstring'],
|
|
550
|
+
ErrorCode.VALIDATION_FIELD_REQUIRED, "函数缺少docstring"),
|
|
551
|
+
|
|
552
|
+
# 无法连接到代码服务器
|
|
553
|
+
(['无法连接到代码服务器'],
|
|
554
|
+
ErrorCode.API_NETWORK_CONNECTION, "代码服务器连接失败"),
|
|
555
|
+
|
|
556
|
+
# JSON解析错误 (中文前缀)
|
|
557
|
+
(['json解析错误'],
|
|
558
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON解析错误"),
|
|
559
|
+
|
|
560
|
+
# Expecting property name (JSON错误)
|
|
561
|
+
(['expecting property name enclosed in double quotes'],
|
|
562
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON格式错误"),
|
|
563
|
+
|
|
564
|
+
# Missing required key(s) (LangGraph状态错误)
|
|
565
|
+
(['missing required key', 'state_schema'],
|
|
566
|
+
ErrorCode.BUSINESS_GRAPH_INVALID, "LangGraph状态缺少必需键"),
|
|
567
|
+
|
|
568
|
+
# 参数数量错误 (中文前缀)
|
|
569
|
+
(['参数数量错误'],
|
|
570
|
+
ErrorCode.CODE_TYPE_EXTRA_ARG, "参数数量错误"),
|
|
571
|
+
|
|
572
|
+
# 路径不存在
|
|
573
|
+
(['路径', '不存在'],
|
|
574
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "路径不存在"),
|
|
575
|
+
|
|
576
|
+
# 对象不可迭代 (中文前缀)
|
|
577
|
+
(['对象不可迭代'],
|
|
578
|
+
ErrorCode.CODE_TYPE_NOT_ITERABLE, "对象不可迭代"),
|
|
579
|
+
|
|
580
|
+
# ==================== 最后的边缘情况补充 ====================
|
|
581
|
+
# INFO 日志误报 (非真正错误)
|
|
582
|
+
(['info:', 'agents.coordinator'],
|
|
583
|
+
ErrorCode.UNKNOWN_EXCEPTION, "日志信息误报"),
|
|
584
|
+
|
|
585
|
+
# API请求无效
|
|
586
|
+
(['api请求无效', 'invalid combination'],
|
|
587
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "API请求参数无效"),
|
|
588
|
+
|
|
589
|
+
# 写入失败 + validation error
|
|
590
|
+
(['写入', '失败', 'validation error'],
|
|
591
|
+
ErrorCode.VALIDATION_FIELD_VALUE, "数据验证失败"),
|
|
592
|
+
|
|
593
|
+
# 视频特征提取失败
|
|
594
|
+
(['视频特征提取失败'],
|
|
595
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "视频特征提取失败"),
|
|
596
|
+
|
|
597
|
+
# keyword argument repeated
|
|
598
|
+
(['keyword argument repeated'],
|
|
599
|
+
ErrorCode.CODE_SYNTAX_INVALID, "关键字参数重复"),
|
|
600
|
+
|
|
601
|
+
# unindent does not match
|
|
602
|
+
(['unindent does not match'],
|
|
603
|
+
ErrorCode.CODE_SYNTAX_INDENTATION, "缩进不匹配"),
|
|
604
|
+
|
|
605
|
+
# invalid character (Unicode错误)
|
|
606
|
+
(['invalid character', 'u+'],
|
|
607
|
+
ErrorCode.CODE_SYNTAX_INVALID, "非法Unicode字符"),
|
|
608
|
+
|
|
609
|
+
# got unexpected keyword arguments
|
|
610
|
+
(['got unexpected keyword argument'],
|
|
611
|
+
ErrorCode.CODE_TYPE_EXTRA_ARG, "函数参数错误"),
|
|
612
|
+
|
|
613
|
+
# 需要配置环境变量
|
|
614
|
+
(['需要配置', '环境变量', 'api_key'],
|
|
615
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "API Key未配置"),
|
|
616
|
+
|
|
617
|
+
# 风格迁移失败
|
|
618
|
+
(['风格迁移失败'],
|
|
619
|
+
ErrorCode.API_IMAGE_GEN_FAILED, "风格迁移失败"),
|
|
620
|
+
|
|
621
|
+
# 内存不足
|
|
622
|
+
(['内存不足', 'bad_alloc'],
|
|
623
|
+
ErrorCode.RUNTIME_MEMORY_ERROR, "内存不足"),
|
|
624
|
+
|
|
625
|
+
# 视频内容分析失败
|
|
626
|
+
(['视频内容分析失败'],
|
|
627
|
+
ErrorCode.RESOURCE_VIDEO_PROCESS_FAILED, "视频内容分析失败"),
|
|
628
|
+
|
|
629
|
+
# execute command error
|
|
630
|
+
(['execute command error'],
|
|
631
|
+
ErrorCode.RUNTIME_EXECUTION_FAILED, "命令执行错误"),
|
|
632
|
+
|
|
633
|
+
# expected 'except' or 'finally' block
|
|
634
|
+
(["expected 'except'", "'finally' block"],
|
|
635
|
+
ErrorCode.CODE_SYNTAX_INVALID, "语法错误:缺少except/finally"),
|
|
636
|
+
|
|
637
|
+
# 视频转存失败
|
|
638
|
+
(['视频转存失败'],
|
|
639
|
+
ErrorCode.RESOURCE_VIDEO_DOWNLOAD_FAILED, "视频转存失败"),
|
|
640
|
+
|
|
641
|
+
# Attribute name is reserved
|
|
642
|
+
(['attribute name', 'is reserved'],
|
|
643
|
+
ErrorCode.CODE_ATTR_NOT_FOUND, "属性名保留字冲突"),
|
|
644
|
+
|
|
645
|
+
# 视频生成超时
|
|
646
|
+
(['视频生成超时'],
|
|
647
|
+
ErrorCode.RUNTIME_TIMEOUT, "视频生成超时"),
|
|
648
|
+
|
|
649
|
+
# ToolRuntime missing arguments
|
|
650
|
+
(['toolruntime', 'missing', 'required positional argument'],
|
|
651
|
+
ErrorCode.CODE_TYPE_MISSING_ARG, "ToolRuntime缺少必需参数"),
|
|
652
|
+
|
|
653
|
+
# SQLAlchemy Table already defined
|
|
654
|
+
(['table', 'is already defined', 'metadata'],
|
|
655
|
+
ErrorCode.INTEGRATION_DB_QUERY, "数据库表定义重复"),
|
|
656
|
+
]
|
|
657
|
+
|
|
658
|
+
TRACEBACK_EXCEPTION_PATTERNS: List[ErrorPattern] = [
|
|
659
|
+
# ==================== Python 内置异常 (从 Traceback 中提取) ====================
|
|
660
|
+
# TypeError 细分
|
|
661
|
+
(['typeerror: got an unexpected keyword argument'],
|
|
662
|
+
ErrorCode.CODE_TYPE_EXTRA_ARG, "函数参数错误"),
|
|
663
|
+
(["typeerror: missing"],
|
|
664
|
+
ErrorCode.CODE_TYPE_MISSING_ARG, "缺少必需参数"),
|
|
665
|
+
(['typeerror: \'nonetype\'', "typeerror: 'nonetype'"],
|
|
666
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "对象为None"),
|
|
667
|
+
(['not callable'],
|
|
668
|
+
ErrorCode.CODE_TYPE_NOT_CALLABLE, "对象不可调用"),
|
|
669
|
+
(['not iterable'],
|
|
670
|
+
ErrorCode.CODE_TYPE_NOT_ITERABLE, "对象不可迭代"),
|
|
671
|
+
(['not subscriptable'],
|
|
672
|
+
ErrorCode.CODE_TYPE_NOT_SUBSCRIPTABLE, "对象不支持下标访问"),
|
|
673
|
+
(['typeerror:'],
|
|
674
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "类型错误"),
|
|
675
|
+
|
|
676
|
+
# ValueError 细分 - 注意:视频/图片相关的 ValueError 放在 ERROR_PATTERNS 中处理
|
|
677
|
+
(['valueerror:'],
|
|
678
|
+
ErrorCode.VALIDATION_FIELD_VALUE, "值错误"),
|
|
679
|
+
|
|
680
|
+
# KeyError / IndexError
|
|
681
|
+
(['keyerror:'],
|
|
682
|
+
ErrorCode.CODE_KEY_NOT_FOUND, "键不存在"),
|
|
683
|
+
(['indexerror:'],
|
|
684
|
+
ErrorCode.CODE_INDEX_OUT_OF_RANGE, "索引越界"),
|
|
685
|
+
|
|
686
|
+
# AttributeError 细分
|
|
687
|
+
(['attributeerror:', 'model_dump'],
|
|
688
|
+
ErrorCode.CODE_ATTR_MODEL_DUMP, "对象类型错误"),
|
|
689
|
+
(["attributeerror: 'nonetype'"],
|
|
690
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "对象为None"),
|
|
691
|
+
(['attributeerror:'],
|
|
692
|
+
ErrorCode.CODE_ATTR_NOT_FOUND, "属性不存在"),
|
|
693
|
+
|
|
694
|
+
# NameError / ImportError
|
|
695
|
+
(['nameerror:'],
|
|
696
|
+
ErrorCode.CODE_NAME_NOT_DEFINED, "名称未定义"),
|
|
697
|
+
(['unboundlocalerror:'],
|
|
698
|
+
ErrorCode.CODE_NAME_NOT_DEFINED, "名称未定义"),
|
|
699
|
+
(['modulenotfounderror:'],
|
|
700
|
+
ErrorCode.CODE_NAME_IMPORT_ERROR, "模块导入错误"),
|
|
701
|
+
(['importerror:'],
|
|
702
|
+
ErrorCode.CODE_NAME_IMPORT_ERROR, "模块导入错误"),
|
|
703
|
+
(['filenotfounderror:'],
|
|
704
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "文件不存在"),
|
|
705
|
+
|
|
706
|
+
# IO 错误
|
|
707
|
+
(['oserror:'],
|
|
708
|
+
ErrorCode.RESOURCE_FILE_READ_ERROR, "文件读取错误"),
|
|
709
|
+
(['ioerror:'],
|
|
710
|
+
ErrorCode.RESOURCE_FILE_READ_ERROR, "文件读取错误"),
|
|
711
|
+
(['cannot open resource'],
|
|
712
|
+
ErrorCode.RESOURCE_FILE_READ_ERROR, "文件读取错误"),
|
|
713
|
+
(['permissionerror:'],
|
|
714
|
+
ErrorCode.RESOURCE_FILE_READ_ERROR, "权限错误"),
|
|
715
|
+
|
|
716
|
+
# 运行时错误
|
|
717
|
+
(['timeouterror:'],
|
|
718
|
+
ErrorCode.RUNTIME_TIMEOUT, "执行超时"),
|
|
719
|
+
(['asyncio.timeouterror'],
|
|
720
|
+
ErrorCode.RUNTIME_TIMEOUT, "执行超时"),
|
|
721
|
+
(['runtimeerror:'],
|
|
722
|
+
ErrorCode.RUNTIME_EXECUTION_FAILED, "运行时错误"),
|
|
723
|
+
(['recursionerror:'],
|
|
724
|
+
ErrorCode.RUNTIME_RECURSION_LIMIT, "递归深度超限"),
|
|
725
|
+
(['memoryerror:'],
|
|
726
|
+
ErrorCode.RUNTIME_MEMORY_ERROR, "内存错误"),
|
|
727
|
+
|
|
728
|
+
# ==================== Pydantic 验证错误 ====================
|
|
729
|
+
(['validationerror:', 'field required'],
|
|
730
|
+
ErrorCode.VALIDATION_FIELD_REQUIRED, "必填字段缺失"),
|
|
731
|
+
(['validationerror:', 'missing'],
|
|
732
|
+
ErrorCode.VALIDATION_FIELD_REQUIRED, "必填字段缺失"),
|
|
733
|
+
(['validationerror:', 'input should be'],
|
|
734
|
+
ErrorCode.VALIDATION_FIELD_TYPE, "字段类型错误"),
|
|
735
|
+
(['validationerror:'],
|
|
736
|
+
ErrorCode.VALIDATION_FIELD_CONSTRAINT, "验证失败"),
|
|
737
|
+
|
|
738
|
+
# ==================== API 相关错误 ====================
|
|
739
|
+
# 下载错误优先 - 防止被通用 apierror 捕获
|
|
740
|
+
(['apierror:', 'error while downloading'],
|
|
741
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "API下载失败"),
|
|
742
|
+
(['apierror:', 'download'],
|
|
743
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "下载失败"),
|
|
744
|
+
(['openai.apierror:', 'error while downloading'],
|
|
745
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "OpenAI下载失败"),
|
|
746
|
+
# model not found
|
|
747
|
+
(['apierror:', 'not found model'],
|
|
748
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "模型不存在"),
|
|
749
|
+
(['apierror:', 'model not found'],
|
|
750
|
+
ErrorCode.API_LLM_MODEL_NOT_FOUND, "模型不存在"),
|
|
751
|
+
(['apierror:', 'rate limit'],
|
|
752
|
+
ErrorCode.API_LLM_RATE_LIMIT, "请求频率超限"),
|
|
753
|
+
(['apierror:', 'token limit'],
|
|
754
|
+
ErrorCode.API_LLM_TOKEN_LIMIT, "Token超限"),
|
|
755
|
+
(['apierror:', 'context_length_exceeded'],
|
|
756
|
+
ErrorCode.API_LLM_TOKEN_LIMIT, "Token超限"),
|
|
757
|
+
(['apierror:', '401'],
|
|
758
|
+
ErrorCode.API_LLM_AUTH_FAILED, "API认证失败"),
|
|
759
|
+
(['apierror:', 'unauthorized'],
|
|
760
|
+
ErrorCode.API_LLM_AUTH_FAILED, "API认证失败"),
|
|
761
|
+
(['apierror:'],
|
|
762
|
+
ErrorCode.API_LLM_REQUEST_FAILED, "API请求失败"),
|
|
763
|
+
|
|
764
|
+
# ==================== LangGraph 错误 ====================
|
|
765
|
+
(['invalidupdateerror', 'expected dict'],
|
|
766
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "节点返回类型错误"),
|
|
767
|
+
(['invalidupdateerror'],
|
|
768
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "节点返回值无效"),
|
|
769
|
+
(['graphrecursionerror'],
|
|
770
|
+
ErrorCode.RUNTIME_RECURSION_LIMIT, "LangGraph递归限制"),
|
|
771
|
+
|
|
772
|
+
# ==================== 网络错误 ====================
|
|
773
|
+
(['connectionerror:'],
|
|
774
|
+
ErrorCode.API_NETWORK_CONNECTION, "网络连接错误"),
|
|
775
|
+
(['connectionrefusederror:'],
|
|
776
|
+
ErrorCode.API_NETWORK_CONNECTION, "网络连接错误"),
|
|
777
|
+
(['httperror:'],
|
|
778
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "HTTP错误"),
|
|
779
|
+
(['httpx.connecterror', 'httpx connecterror'],
|
|
780
|
+
ErrorCode.API_NETWORK_CONNECTION, "HTTPX连接错误"),
|
|
781
|
+
(['httpx.timeout', 'httpx timeout'],
|
|
782
|
+
ErrorCode.API_NETWORK_TIMEOUT, "HTTPX超时错误"),
|
|
783
|
+
(['remoteprotocolerror'],
|
|
784
|
+
ErrorCode.API_NETWORK_REMOTE_PROTOCOL, "远程协议错误"),
|
|
785
|
+
|
|
786
|
+
# ==================== 其他错误 ====================
|
|
787
|
+
(['zerodivisionerror:'],
|
|
788
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "除零错误"),
|
|
789
|
+
(['assertionerror:'],
|
|
790
|
+
ErrorCode.VALIDATION_FIELD_VALUE, "断言错误"),
|
|
791
|
+
(['subprocesserror:'],
|
|
792
|
+
ErrorCode.RUNTIME_SUBPROCESS_FAILED, "子进程执行失败"),
|
|
793
|
+
]
|
|
794
|
+
|
|
795
|
+
CUSTOM_EXCEPTION_PATTERNS: List[ErrorPattern] = [
|
|
796
|
+
# ==================== 视频相关 ====================
|
|
797
|
+
(['视频生成失败'],
|
|
798
|
+
ErrorCode.API_VIDEO_GEN_FAILED, "视频生成失败"),
|
|
799
|
+
(['没有生成任何视频片段', '视频片段生成失败'],
|
|
800
|
+
ErrorCode.RESOURCE_VIDEO_SEGMENT_FAILED, "视频片段生成失败"),
|
|
801
|
+
(['无法下载任何视频片段', '视频下载失败'],
|
|
802
|
+
ErrorCode.RESOURCE_VIDEO_DOWNLOAD_FAILED, "视频下载失败"),
|
|
803
|
+
(['failed to merge video', 'failed to create video'],
|
|
804
|
+
ErrorCode.RESOURCE_FFMPEG_FAILED, "视频合并失败"),
|
|
805
|
+
(['视频合成失败', '视频合并失败'],
|
|
806
|
+
ErrorCode.RESOURCE_FFMPEG_FAILED, "视频合成失败"),
|
|
807
|
+
|
|
808
|
+
# ==================== 图片相关 ====================
|
|
809
|
+
(['无法下载图片', '图片下载失败'],
|
|
810
|
+
ErrorCode.RESOURCE_IMAGE_DOWNLOAD_FAILED, "图片下载失败"),
|
|
811
|
+
(['敏感内容', 'sensitive content'],
|
|
812
|
+
ErrorCode.API_LLM_CONTENT_FILTER, "内容被安全过滤"),
|
|
813
|
+
(['提交文生图任务失败'],
|
|
814
|
+
ErrorCode.API_IMAGE_GEN_FAILED, "文生图任务失败"),
|
|
815
|
+
(['图片识别失败'],
|
|
816
|
+
ErrorCode.RESOURCE_IMAGE_PROCESS_FAILED, "图片识别失败"),
|
|
817
|
+
|
|
818
|
+
# ==================== 下载相关 ====================
|
|
819
|
+
(['下载失败', 'download failed'],
|
|
820
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "下载失败"),
|
|
821
|
+
(['所有下载策略都失败'],
|
|
822
|
+
ErrorCode.RESOURCE_S3_DOWNLOAD_FAILED, "所有下载策略失败"),
|
|
823
|
+
|
|
824
|
+
# ==================== API 相关 ====================
|
|
825
|
+
(['api调用失败', 'api请求失败', 'api call failed'],
|
|
826
|
+
ErrorCode.API_LLM_REQUEST_FAILED, "API调用失败"),
|
|
827
|
+
(['llm调用失败', '大模型调用失败'],
|
|
828
|
+
ErrorCode.API_LLM_REQUEST_FAILED, "LLM调用失败"),
|
|
829
|
+
(['pixabay'],
|
|
830
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "Pixabay API失败"),
|
|
831
|
+
(['和风天气', 'qweather'],
|
|
832
|
+
ErrorCode.API_NETWORK_HTTP_ERROR, "和风天气API失败"),
|
|
833
|
+
|
|
834
|
+
# ==================== 解析相关 ====================
|
|
835
|
+
(['解析失败', 'parse failed'],
|
|
836
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "解析失败"),
|
|
837
|
+
(['无法解析json', 'json解析失败', 'json decode error'],
|
|
838
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON解析失败"),
|
|
839
|
+
|
|
840
|
+
# ==================== 配置相关 ====================
|
|
841
|
+
(['请在config', '请设置环境变量'],
|
|
842
|
+
ErrorCode.CONFIG_ENV_MISSING, "配置缺失"),
|
|
843
|
+
(['access key', 'api_key缺失', 'api key missing'],
|
|
844
|
+
ErrorCode.CONFIG_API_KEY_MISSING, "API Key缺失"),
|
|
845
|
+
|
|
846
|
+
# ==================== 文件相关 ====================
|
|
847
|
+
(['不支持的文件类型'],
|
|
848
|
+
ErrorCode.RESOURCE_FILE_FORMAT_ERROR, "不支持的文件类型"),
|
|
849
|
+
(['上传失败', 'upload failed'],
|
|
850
|
+
ErrorCode.RESOURCE_S3_UPLOAD_FAILED, "上传失败"),
|
|
851
|
+
(['no such file or directory', 'no such file'],
|
|
852
|
+
ErrorCode.RESOURCE_FILE_NOT_FOUND, "文件不存在"),
|
|
853
|
+
|
|
854
|
+
# ==================== 天气/外部服务 ====================
|
|
855
|
+
(['无法获取实时天气', '无法获取天气'],
|
|
856
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "天气服务不可用"),
|
|
857
|
+
(['无法使用浏览器截图', '无法使用浏览器'],
|
|
858
|
+
ErrorCode.CONFIG_WEBDRIVER_FAILED, "浏览器截图失败"),
|
|
859
|
+
|
|
860
|
+
# ==================== 类型/键错误 ====================
|
|
861
|
+
(['can only concatenate str'],
|
|
862
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "字符串拼接类型错误"),
|
|
863
|
+
(['键不存在', 'keyerror'],
|
|
864
|
+
ErrorCode.CODE_KEY_NOT_FOUND, "键不存在"),
|
|
865
|
+
(['缺少必需参数', 'missing required positional'],
|
|
866
|
+
ErrorCode.CODE_TYPE_MISSING_ARG, "缺少必需参数"),
|
|
867
|
+
|
|
868
|
+
# ==================== JSON/格式错误 ====================
|
|
869
|
+
(['expecting property name enclosed in double quotes'],
|
|
870
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON属性名格式错误"),
|
|
871
|
+
(['extra data:', 'line 1 column'],
|
|
872
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON包含多余数据"),
|
|
873
|
+
(['invalid json format'],
|
|
874
|
+
ErrorCode.VALIDATION_JSON_DECODE, "JSON格式无效"),
|
|
875
|
+
|
|
876
|
+
# ==================== 运行时错误 ====================
|
|
877
|
+
(['no current event loop', 'threadpoolexecutor'],
|
|
878
|
+
ErrorCode.RUNTIME_ASYNC_NOT_IMPL, "事件循环错误"),
|
|
879
|
+
(['视频生成过程出错', '403 client error', 'forbidden'],
|
|
880
|
+
ErrorCode.API_LLM_AUTH_FAILED, "视频生成权限错误"),
|
|
881
|
+
(['无法连接到代码服务器', '服务可能未启动'],
|
|
882
|
+
ErrorCode.INTEGRATION_SERVICE_UNAVAILABLE, "代码服务器不可用"),
|
|
883
|
+
(["'<' not supported between", "not supported between instances"],
|
|
884
|
+
ErrorCode.CODE_TYPE_WRONG_ARG, "类型比较错误"),
|
|
885
|
+
(['time data', 'does not match format'],
|
|
886
|
+
ErrorCode.VALIDATION_FIELD_FORMAT, "时间格式错误"),
|
|
887
|
+
(['missing required key', 'state_schema'],
|
|
888
|
+
ErrorCode.VALIDATION_FIELD_REQUIRED, "状态字段缺失"),
|
|
889
|
+
(['tool_calls that do not have', 'toolmessage'],
|
|
890
|
+
ErrorCode.API_LLM_INVALID_REQUEST, "工具调用消息不匹配"),
|
|
891
|
+
(['需要.*张.*图', '当前只有'],
|
|
892
|
+
ErrorCode.VALIDATION_INPUT_INVALID, "图片数量不足"),
|
|
893
|
+
(['takes 1 positional argument', 'positional argument but'],
|
|
894
|
+
ErrorCode.CODE_TYPE_EXTRA_ARG, "参数数量错误"),
|
|
895
|
+
(["unsupported operand type", "nonetype"],
|
|
896
|
+
ErrorCode.CODE_ATTR_WRONG_TYPE, "None类型操作错误"),
|
|
897
|
+
]
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
def match_error_pattern(
|
|
901
|
+
error_str: str,
|
|
902
|
+
patterns: List[ErrorPattern] = None,
|
|
903
|
+
require_all: bool = False
|
|
904
|
+
) -> Tuple[Optional[int], Optional[str]]:
|
|
905
|
+
"""
|
|
906
|
+
使用模式表匹配错误消息
|
|
907
|
+
|
|
908
|
+
Args:
|
|
909
|
+
error_str: 错误消息字符串
|
|
910
|
+
patterns: 要使用的模式表,默认使用 ERROR_PATTERNS
|
|
911
|
+
require_all: 是否要求所有关键词都匹配(默认只需匹配一个)
|
|
912
|
+
|
|
913
|
+
Returns:
|
|
914
|
+
(error_code, error_message) 或 (None, None) 如果没有匹配
|
|
915
|
+
"""
|
|
916
|
+
if patterns is None:
|
|
917
|
+
patterns = ERROR_PATTERNS
|
|
918
|
+
|
|
919
|
+
error_lower = error_str.lower()
|
|
920
|
+
|
|
921
|
+
for keywords, code, msg_template in patterns:
|
|
922
|
+
if require_all:
|
|
923
|
+
if all(kw.lower() in error_lower for kw in keywords):
|
|
924
|
+
return code, f"{msg_template}: {error_str[:200]}"
|
|
925
|
+
else:
|
|
926
|
+
if any(kw.lower() in error_lower for kw in keywords):
|
|
927
|
+
return code, f"{msg_template}: {error_str[:200]}"
|
|
928
|
+
|
|
929
|
+
return None, None
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
def match_traceback_pattern(error_str: str) -> Tuple[Optional[int], Optional[str]]:
|
|
933
|
+
"""匹配 Traceback 中的异常类型"""
|
|
934
|
+
return match_error_pattern(error_str, TRACEBACK_EXCEPTION_PATTERNS)
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
def match_custom_exception_pattern(error_str: str) -> Tuple[Optional[int], Optional[str]]:
|
|
938
|
+
"""匹配自定义 Exception 的模式"""
|
|
939
|
+
return match_error_pattern(error_str, CUSTOM_EXCEPTION_PATTERNS)
|