From 6f234cdeff482c65c2bb09074f0f8d94f84f2928 Mon Sep 17 00:00:00 2001 From: dantecatalfamo Date: Thu, 26 Sep 2024 11:51:30 -0400 Subject: [PATCH] Provide information about why context was cancelled on command fail --- orbit/pkg/swiftdialog/run.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/orbit/pkg/swiftdialog/run.go b/orbit/pkg/swiftdialog/run.go index 01eb3df60705..f117301da572 100644 --- a/orbit/pkg/swiftdialog/run.go +++ b/orbit/pkg/swiftdialog/run.go @@ -17,6 +17,7 @@ import ( var CommandFilePerms = fs.FileMode(0666) var ErrKilled = errors.New("process killed") +var ErrWindowClosed = errors.New("window closed") type SwiftDialog struct { cancel context.CancelCauseFunc @@ -104,7 +105,7 @@ func Create(ctx context.Context, swiftDialogBin string, options *SwiftDialogOpti } } close(sd.done) - cancel(nil) + cancel(ErrWindowClosed) }() return sd, nil @@ -161,7 +162,7 @@ func (s *SwiftDialog) Wait() (*SwiftDialogExit, error) { func (s *SwiftDialog) sendCommand(command, arg string) error { if err := s.context.Err(); err != nil { - return fmt.Errorf("could not send command: %w", err) + return fmt.Errorf("could not send command: %w", context.Cause(s.context)) } // For some reason swiftDialog needs us to open and close the file // to detect a new command, just writing to the file doesn't cause