From 0edbb6f57a7d79a4e9a2af78baf0520a41aa1c27 Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 9 Jul 2024 10:42:54 +0200 Subject: [PATCH] Fix mix-up in error message when aborting (#428) --- internal/adapter/editor/editor.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/adapter/editor/editor.go b/internal/adapter/editor/editor.go index f02058b..733347e 100644 --- a/internal/adapter/editor/editor.go +++ b/internal/adapter/editor/editor.go @@ -3,6 +3,7 @@ package editor import ( "fmt" "os" + "os/exec" "strings" "github.com/kballard/go-shellquote" @@ -43,5 +44,12 @@ func (e *Editor) Open(paths ...string) error { cmd.Stdout = os.Stdout 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, " ")) + + } }