From 94267111b8a2d4cd86b56ada42e27b1f702a157b Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 15 Dec 2025 21:33:28 -0500 Subject: [PATCH] chore(lazygit): log errors --- internal/tui/components/dialogs/lazygit/lazygit.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/tui/components/dialogs/lazygit/lazygit.go b/internal/tui/components/dialogs/lazygit/lazygit.go index 303ba5f622aff6863e511dae3a5315ea6b5095e7..f2a9257508f6db6ea7f76cf7cba16b1d8824985e 100644 --- a/internal/tui/components/dialogs/lazygit/lazygit.go +++ b/internal/tui/components/dialogs/lazygit/lazygit.go @@ -5,6 +5,7 @@ import ( "context" "fmt" "image/color" + "log/slog" "os" "path/filepath" @@ -38,7 +39,9 @@ func NewDialog(ctx context.Context, workingDir string) *termdialog.Dialog { Term: terminal.New(terminal.Config{Context: ctx, Cmd: cmd}), OnClose: func() { if themeConfig != "" { - _ = os.Remove(themeConfig) + if err := os.Remove(themeConfig); err != nil { + slog.Debug("failed to remove lazygit theme config", "error", err, "path", themeConfig) + } } }, }) @@ -61,6 +64,7 @@ func buildConfigEnv(themeConfig string) string { func defaultConfigPath() string { configDir, err := os.UserConfigDir() if err != nil { + slog.Debug("failed to get user config directory", "error", err) return "" } return filepath.Join(configDir, "lazygit", "config.yml") @@ -126,10 +130,15 @@ gui: f, err := os.CreateTemp("", "crush-lazygit-*.yml") if err != nil { + slog.Error("failed to create temporary lazygit config", "error", err) return "" } defer f.Close() - _, _ = f.WriteString(config) + if _, err := f.WriteString(config); err != nil { + slog.Error("failed to write lazygit theme config", "error", err) + _ = os.Remove(f.Name()) // remove the empty file + return "" + } return f.Name() }