From 9f4227d37861621eca6fd102f64bd7c3f33de117 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 22 Mar 2024 14:09:27 +0100 Subject: [PATCH] term: Improve errors when editor can't be spawned --- radicle-term/src/editor.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/radicle-term/src/editor.rs b/radicle-term/src/editor.rs index 0586f2ce..ae1b7bb1 100644 --- a/radicle-term/src/editor.rs +++ b/radicle-term/src/editor.rs @@ -83,13 +83,25 @@ impl Editor { process::Stdio::from(tty) }; - process::Command::new(cmd) + process::Command::new(&cmd) .stdout(unsafe { process::Stdio::from_raw_fd(stderr) }) .stderr(process::Stdio::inherit()) .stdin(stdin) .arg(&self.path) - .spawn()? - .wait()?; + .spawn() + .map_err(|e| { + io::Error::new( + e.kind(), + format!("failed to spawn editor command {cmd:?}: {e}"), + ) + })? + .wait() + .map_err(|e| { + io::Error::new( + e.kind(), + format!("editor command {cmd:?} didn't spawn: {e}"), + ) + })?; let text = fs::read_to_string(&self.path)?; if text.trim().is_empty() {