From 60221bd45769e9baa9a90ed66c35142308c4222f Mon Sep 17 00:00:00 2001 From: imeepos Date: Fri, 8 Aug 2025 16:35:41 +0800 Subject: [PATCH] fix: cargo check --lib error --- .../src/business/services/error_handler.rs | 20 +++++++++++-------- .../src/business/services/service_manager.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/desktop/src-tauri/src/business/services/error_handler.rs b/apps/desktop/src-tauri/src/business/services/error_handler.rs index c378a69..e29d32f 100644 --- a/apps/desktop/src-tauri/src/business/services/error_handler.rs +++ b/apps/desktop/src-tauri/src/business/services/error_handler.rs @@ -8,7 +8,7 @@ use tracing::{error, warn, info, debug}; use serde::{Serialize, Deserialize}; /// 统一错误类型 -#[derive(Debug, thiserror::Error)] +#[derive(Debug, Clone, thiserror::Error)] pub enum ComfyUIError { /// 连接错误 #[error("连接错误: {message}")] @@ -60,7 +60,13 @@ pub enum ComfyUIError { /// SDK 错误 #[error("SDK 错误: {0}")] - Sdk(#[from] comfyui_sdk::error::ComfyUIError), + Sdk(String), +} + +impl From for ComfyUIError { + fn from(error: comfyui_sdk::error::ComfyUIError) -> Self { + ComfyUIError::Sdk(error.to_string()) + } } impl ComfyUIError { @@ -72,12 +78,10 @@ impl ComfyUIError { ComfyUIError::Timeout { .. } => true, ComfyUIError::ResourceExhausted { .. } => true, ComfyUIError::Sdk(sdk_error) => { - // 根据 SDK 错误类型判断是否可重试 - matches!(sdk_error, - comfyui_sdk::error::ComfyUIError::Http(_) | - comfyui_sdk::error::ComfyUIError::Timeout(_) | - comfyui_sdk::error::ComfyUIError::Connection(_) - ) + // 检查 SDK 错误字符串是否包含可重试的错误类型 + sdk_error.contains("Http") || + sdk_error.contains("Timeout") || + sdk_error.contains("Connection") } _ => false, } diff --git a/apps/desktop/src-tauri/src/business/services/service_manager.rs b/apps/desktop/src-tauri/src/business/services/service_manager.rs index 8219595..0407213 100644 --- a/apps/desktop/src-tauri/src/business/services/service_manager.rs +++ b/apps/desktop/src-tauri/src/business/services/service_manager.rs @@ -68,7 +68,7 @@ impl ServiceManager { } // 初始化数据库 - self.repository.initialize().await?; + self.repository.initialize()?; // 获取配置 let config = self.config_manager.get_comfyui_config().await;