From 2d5b152dc0b2b9e726fc679e7e28e8f03130321c Mon Sep 17 00:00:00 2001 From: LuckyPuppy514 <122154133@qq.com> Date: Sat, 30 Nov 2024 15:50:49 +0800 Subject: [PATCH] =?UTF-8?q?v1.0.3=20=E4=BC=98=E5=8C=96=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- src/main.rs | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 864cf16..5f2c7dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "url-scheme-handler" -version = "1.0.2" +version = "1.0.3" edition = "2021" [dependencies] diff --git a/src/main.rs b/src/main.rs index 4b2eb94..0b8faa4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -145,17 +145,24 @@ fn main() -> std::io::Result<()> { { app_path = app.path.as_deref().unwrap_or(""); println!("Executing command: {} {}", app_path, args); - let output = Command::new(app_path) - .raw_arg(args) - .output() - .expect("Failed to execute command"); - - if output.status.success() { - let stdout = String::from_utf8_lossy(&output.stdout); - println!("Output: {}", stdout); - } else { - let stderr = String::from_utf8_lossy(&output.stderr); - show_message_box("Error", &stderr); + let output = Command::new(app_path).raw_arg(args).output(); + + match output { + Ok(output) => { + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + show_message_box("Error", &stderr); + } else { + println!("Command executed successfully"); + } + } + Err(e) => { + show_message_box( + "Error", + &format!("{}\n{}", app_path, &e.to_string()), + ); + open_setting_widow(); + } } } else { show_message_box(