fix: log some error

This commit is contained in:
GyDi 2022-03-09 02:00:56 +08:00
parent 68450d2042
commit 109fb39e09
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -181,21 +181,23 @@ pub fn view_profile(index: String, profiles_state: State<'_, ProfilesState>) ->
{ {
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
return match Command::new(code) if let Err(err) = Command::new(code)
.creation_flags(0x08000000) .creation_flags(0x08000000)
.arg(path) .arg(path)
.spawn() .spawn()
{ {
Ok(_) => Ok(()), log::error!("{err}");
Err(_) => Err("failed to open file by VScode".into()), return Err("failed to open file by VScode".into());
}; }
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
return match Command::new(code).arg(path).spawn() { if let Err(err) = Command::new(code).arg(path).spawn() {
Ok(_) => Ok(()), log::error!("{err}");
Err(_) => Err("failed to open file by VScode".into()), return Err("failed to open file by VScode".into());
}; }
return Ok(());
} }
open_path_cmd(path, "failed to open file by `open`") open_path_cmd(path, "failed to open file by `open`")
@ -317,19 +319,21 @@ fn open_path_cmd(dir: PathBuf, err_str: &str) -> Result<(), String> {
{ {
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
match Command::new("explorer") if let Err(err) = Command::new("explorer")
.creation_flags(0x08000000) .creation_flags(0x08000000)
.arg(dir) .arg(dir)
.spawn() .spawn()
{ {
Ok(_) => Ok(()), log::error!("{err}");
Err(_) => Err(err_str.into()), return Err(err_str.into());
} }
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
match Command::new("open").arg(dir).spawn() { if let Err(err) = Command::new("open").arg(dir).spawn() {
Ok(_) => Ok(()), log::error!("{err}");
Err(_) => Err(err_str.into()), return Err(err_str.into());
} }
return Ok(());
} }