fix: replace bare except clauses with except Exception in llmcore.py#529
Open
Kailigithub wants to merge 1 commit into
Open
fix: replace bare except clauses with except Exception in llmcore.py#529Kailigithub wants to merge 1 commit into
Kailigithub wants to merge 1 commit into
Conversation
Replace bare `except:` with `except Exception:` at 17 locations in llmcore.py covering SSE parsing, JSON parsing, retry logic, and HTTP response handling. This improves error specificity and debuggability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复 llmcore.py 中 17 处裸
except:子句修改范围
在
llmcore.py中将所有裸except:替换为except Exception:,涉及以下函数:_load_mykeys(): 配置文件加载容错_parse_claude_sse(): Claude SSE 事件解析中的 JSON 解析容错(2处)_try_parse_tool_args(): 工具参数 JSON 解析容错(3处)_parse_openai_sse(): OpenAI SSE 事件解析容错_parse_anthropic_sse(): Anthropic SSE 解析容错_parse_openai_resp_text(): OpenAI 响应解析容错retry_request(): HTTP 重试逻辑中的 retry-after 解析和响应体读取容错(2处)_parse_tool_calls_block(): 工具调用块 JSON 解析容错(2处)tryparse(): JSON 字符串解析容错(3处)验证
python3 -m py_compile llmcore.py)E722检查在 llmcore.py 中已全部通过 (All checks passed!)except:为except Exception:,不改变任何业务逻辑影响
无功能性变更。所有
except Exception:捕获行为与原except:完全一致,但提供了更精确的错误类型信息,有助于生产环境调试。Closes #476