tenseleyflow/gump / 9f525f8

Browse files

improve error when editor not found in gump edit

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
9f525f88a4c71b128172e41efb4d2aa5df11c4b8
Parents
08d3dc2
Tree
71a8824

1 changed file

StatusFile+-
M src/cmd/edit.rs 13 1
src/cmd/edit.rsmodified
@@ -50,7 +50,19 @@ pub fn run() -> Result<()> {
5050
         .unwrap_or_else(|_| "vi".to_string());
5151
 
5252
     // Open in editor
53
-    let status = Command::new(&editor).arg(&temp_path).status()?;
53
+    let status = Command::new(&editor)
54
+        .arg(&temp_path)
55
+        .status()
56
+        .map_err(|e| {
57
+            if e.kind() == std::io::ErrorKind::NotFound {
58
+                CmdError::Other(format!(
59
+                    "editor '{}' not found. Set $EDITOR or $VISUAL to an installed editor",
60
+                    editor
61
+                ))
62
+            } else {
63
+                CmdError::Io(e)
64
+            }
65
+        })?;
5466
 
5567
     if !status.success() {
5668
         return Err(CmdError::Other("Editor exited with error".to_string()));