refactor(i18n): complete error message internationalization and code cleanup
Replaced all remaining hardcoded error types with AppError::localized for full bilingual support and simplified error handling logic. Backend changes: - usage_script.rs: Converted InvalidHttpMethod to localized error - provider.rs: Replaced all 7 ProviderNotFound instances with localized errors * Line 436: Delete provider validation * Line 625: Update provider metadata * Line 785: Test usage script provider lookup * Line 855: Query usage provider lookup * Line 924: Prepare Codex provider switch * Line 1011: Prepare Claude provider switch * Line 1272: Delete provider snapshot - provider.rs: Simplified error message formatting (removed 40+ lines) * Removed redundant string matching fallback logic * Now uses clean language-based selection for Localized errors * Falls back to default Display for other error types - error.rs: Removed unused error variants * Deleted InvalidHttpMethod (replaced with localized) * Deleted ProviderNotFound (replaced with localized) Code quality improvements: - Reduced complexity: 40+ lines of string matching removed - Better maintainability: Centralized error message handling - Type safety: All provider errors now use consistent localized format Impact: - 100% i18n coverage for provider and usage script error messages - Cleaner, more maintainable error handling code - No unused error variants remaining
This commit is contained in:
@@ -40,14 +40,10 @@ pub enum AppError {
|
||||
},
|
||||
#[error("锁获取失败: {0}")]
|
||||
Lock(String),
|
||||
#[error("供应商不存在: {0}")]
|
||||
ProviderNotFound(String),
|
||||
#[error("MCP 校验失败: {0}")]
|
||||
McpValidation(String),
|
||||
#[error("{0}")]
|
||||
Message(String),
|
||||
#[error("不支持的 HTTP 方法: {0}")]
|
||||
InvalidHttpMethod(String),
|
||||
#[error("{zh} ({en})")]
|
||||
Localized {
|
||||
key: &'static str,
|
||||
|
||||
Reference in New Issue
Block a user