Fix mix-up in error message when aborting (#428)

This commit is contained in:
Hugo 2024-07-09 10:42:54 +02:00 committed by GitHub
parent 00a4361d20
commit 0edbb6f57a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package editor
import ( import (
"fmt" "fmt"
"os" "os"
"os/exec"
"strings" "strings"
"github.com/kballard/go-shellquote" "github.com/kballard/go-shellquote"
@ -43,5 +44,12 @@ func (e *Editor) Open(paths ...string) error {
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
return errors.Wrapf(cmd.Run(), "failed to launch editor: %s %s", e.editor, strings.Join(paths, " ")) err := cmd.Run()
switch err.(type) {
case *exec.ExitError:
return errors.Wrapf(err, "operation aborted by editor: %s %s", e.editor, strings.Join(paths, " "))
default:
return errors.Wrapf(err, "failed to launch editor: %s %s", e.editor, strings.Join(paths, " "))
}
} }