diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src-tauri/src/commands.rs b/plugins/mindstudio-insight-plugins/ModelVis/app/src-tauri/src/commands.rs index 4a80e78a4a8c86eb0426159f0efd1ef6b5abb855..a5c083374c0c87a3f9b3228cfc312c8488fdd029 100644 --- a/plugins/mindstudio-insight-plugins/ModelVis/app/src-tauri/src/commands.rs +++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src-tauri/src/commands.rs @@ -14,6 +14,7 @@ use csv_parser::operator::OperatorGroup; use csv_parser::parse_operator_csv; use path_validator::{FileErrorKind, FileExt}; use crate::errors::{app_error::AppResult, convert::convert_error, fsg::FSGErrorEnum}; +use crate::errors::app_error::AppError; #[allow(non_snake_case)] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -202,8 +203,18 @@ pub struct GraphLayer { #[tauri::command] pub fn layout_bin(handle: AppHandle, path: String) -> AppResult { - let script_path = handle.path().resolve("resources/bin.ts", BaseDirectory::Resource)?; - + let resolve_result = handle.path().resolve("resources/bin.ts", BaseDirectory::Resource); + let script_path; + match resolve_result { + Ok(p) => { script_path = p } + Err(error) => { return Err(AppError::Anyhow { + code: 9999, // 临时使用通用内部错误码 + message_en: "Load resources fail".to_string(), + message_cn: "加载资源失败".to_string(), + backtrace: error.to_string(), + }); } + } + let s1 = Instant::now(); check_path(&path)?; let model = parse_bin(&path)?; @@ -211,7 +222,16 @@ pub fn layout_bin(handle: AppHandle, path: String) -> AppResult { let tmp_folder = home_dir().unwrap().join(".llm_visual"); if !tmp_folder.exists() { - create_dir_750(&tmp_folder)?; + let result = create_dir_750(&tmp_folder); + match result { + Ok(_) => { /* do nothing */ } + Err(error) => { return Err(AppError::Anyhow { + code: 9999, // 临时使用通用内部错误码 + message_en: "Create .llm_visual directory fail".to_string(), + message_cn: "创建 .llm_visual 文件夹失败".to_string(), + backtrace: error.to_string(), + }); } + } } let dst = tmp_folder.join("rs.json"); let s2 = Instant::now();