Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term: Improve errors when editor can't be spawned
cloudhead committed 2 years ago
commit 9f4227d37861621eca6fd102f64bd7c3f33de117
parent 0581c017ae1fa7cd3d553c855c439d40e12357e9
1 file changed +15 -3
modified 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() {