From 7552906f9a2bab62bf9ea89b946c5007ef3a6563 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 6 Oct 2024 10:28:10 +0800 Subject: [PATCH] feat: Out more error info with cmd run failed --- src/ops/cmd.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ops/cmd.rs b/src/ops/cmd.rs index e4b6c78bf..1196fcac5 100644 --- a/src/ops/cmd.rs +++ b/src/ops/cmd.rs @@ -38,12 +38,17 @@ fn do_call( } } + let ctx_dir = match path { + Some(p) => format!(" within {}", p.display()), + None => String::new(), + }; + let mut child = cmd .spawn() - .map_err(|e| anyhow::format_err!("failed to launch `{cmd_name}`: {e}"))?; + .map_err(|e| anyhow::format_err!("failed to launch `{cmd_name}`{ctx_dir}: {e}"))?; let result = child .wait() - .map_err(|e| anyhow::format_err!("failed to launch `{cmd_name}`: {e}"))?; + .map_err(|e| anyhow::format_err!("failed to launch `{cmd_name}`{ctx_dir}: {e}"))?; Ok(result.success()) }