From d70ed7c4fc48b441ef57347c686ecd637c806208 Mon Sep 17 00:00:00 2001 From: ityuany <519495771@qq.com> Date: Mon, 22 Jul 2024 01:11:17 +0800 Subject: [PATCH] better error msg --- crates/snm_shim/src/lib.rs | 7 +++++-- crates/snm_utils/src/snm_error.rs | 6 +----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/snm_shim/src/lib.rs b/crates/snm_shim/src/lib.rs index 69e6cff3..51d32bd6 100644 --- a/crates/snm_shim/src/lib.rs +++ b/crates/snm_shim/src/lib.rs @@ -43,8 +43,11 @@ pub async fn load_package_manage_shim(prefix: &str, bin_name: &str) -> Result<() ensure_binary_path(&snm_package_manage, &version).await?, ] } else if restricted_list.contains(&command.as_str()) { - return Err(SnmError::CannotFindDefaultCommand { - command: bin_name.to_string(), + return Err(SnmError::NotMatchPackageManagerError { + // command: bin_name.to_string(), + raw_command: args_all.join(" ").to_string(), + expected: package_manager.name, + actual: prefix.to_string(), }); } else { vec![node_dir.clone(), get_default_bin_dir(&node_dir, bin_name)?] diff --git a/crates/snm_utils/src/snm_error.rs b/crates/snm_utils/src/snm_error.rs index 65c846ca..5496714a 100644 --- a/crates/snm_utils/src/snm_error.rs +++ b/crates/snm_utils/src/snm_error.rs @@ -217,11 +217,7 @@ pub fn friendly_error_message(error: SnmError) { actual, } => { eprintln!( - r##" - 👹 You Input: {} , Package Manager not match - - The expected packageManager is {} , but the actual packageManager is {}. - "##, + r##"You input: {} , packageManager not match. The expected packageManager is {} , but the actual packageManager is {}."##, raw_command.bold().red(), expected.green(), actual.red()