优化: R-PD-10 commands err_str helper 统一错误格式化(87 处)

mod.rs 加 pub fn err_str<E: ToString>,commands/ 10 文件 87 处 .map_err(|e| e.to_string()) → .map_err(err_str),残留 0(10 处复杂表达式 e 用于 format!/anyhow 保留)。行为零变化,统一入口为未来加日志/分类留点。批5,cargo workspace 0
This commit is contained in:
lxy
2026-06-15 05:45:04 +08:00
parent fddca9daf1
commit 892a642bd4
11 changed files with 105 additions and 94 deletions
+3 -2
View File
@@ -2,6 +2,7 @@
use df_storage::models::AiProviderRecord;
use crate::commands::err_str;
use crate::state::AppState;
/// 获取当前活跃提供商配置
@@ -12,7 +13,7 @@ pub(crate) async fn get_active_provider(state: &AppState) -> Result<AiProviderRe
.ai_providers
.get_by_id(pid)
.await
.map_err(|e| e.to_string())?
.map_err(err_str)?
.ok_or_else(|| format!("活跃提供商不存在: {}", pid))?;
Ok(provider)
} else {
@@ -22,7 +23,7 @@ pub(crate) async fn get_active_provider(state: &AppState) -> Result<AiProviderRe
.ai_providers
.list_all()
.await
.map_err(|e| e.to_string())?;
.map_err(err_str)?;
let default = providers.iter().find(|p| p.is_default).cloned();
default
.or_else(|| providers.into_iter().next())