From cabcd54508a162d58a8ee6108064b09849c21a71 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 9 May 2025 09:31:42 +0200 Subject: [PATCH] Include migration changes in the error message if we can't log them This is for the unlikely case that a repo-local config file can't be written back after migration; in this case we can't log the migration changes to the console, so include them in the error popup instead. --- pkg/config/app_config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 560031cc1..e3bc4cd40 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -250,7 +250,11 @@ func migrateUserConfig(path string, content []byte, isGuiInitialized bool) ([]by fmt.Println(changesText) } if err := os.WriteFile(path, changedContent, 0o644); err != nil { - return nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err) + errorMsg := fmt.Sprintf("While attempting to write back migrated user config to %s, an error occurred: %s", path, err) + if isGuiInitialized { + errorMsg += "\n\n" + changesText + } + return nil, errors.New(errorMsg) } if !isGuiInitialized { fmt.Printf("Config file saved successfully to %s\n", path)