From b19bc96d6b7ee1bf6b5f217629edb8b1d1b7413a Mon Sep 17 00:00:00 2001 From: Samuel K Date: Sat, 25 Apr 2026 14:24:39 -0500 Subject: [PATCH] fix(ux): print error message on SSH/exec exit failures Replace silent os.Exit calls with log.Errorf messages before exiting, so users see what failed. Replace log.Fatal with log.Errorf + os.Exit(1) to allow deferred cleanup functions to run. --- cmd/root.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d0a46a260..f332c432f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -74,23 +74,26 @@ func Execute() { if err != nil { //nolint:all if sshExitErr, ok := err.(*ssh.ExitError); ok { + log.Errorf("SSH command failed with exit code %d", sshExitErr.ExitStatus()) os.Exit(sshExitErr.ExitStatus()) } //nolint:all if execExitErr, ok := err.(*exec.ExitError); ok { + log.Errorf("Command failed with exit code %d", execExitErr.ExitCode()) os.Exit(execExitErr.ExitCode()) } if globalFlags.Debug { - log.Fatalf("%+v", err) + log.Errorf("%+v", err) } else { if rootCmd.Annotations == nil || rootCmd.Annotations[agent.AgentExecutedAnnotation] != config.BoolTrue { log.Error("Try using -v or --debug flag to see more verbose output") } - log.Fatal(err) + log.Errorf("%v", err) } + os.Exit(1) } }