Skip to content

Commit ca02207

Browse files
committed
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.
1 parent 3b904c1 commit ca02207

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/config/app_config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ func migrateUserConfig(path string, content []byte, isGuiInitialized bool) ([]by
244244
fmt.Println(changesText)
245245
}
246246
if err := os.WriteFile(path, changedContent, 0o644); err != nil {
247-
return nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err)
247+
errorMsg := fmt.Sprintf("While attempting to write back migrated user config to %s, an error occurred: %s", path, err)
248+
if isGuiInitialized {
249+
errorMsg += "\n\n" + changesText
250+
}
251+
return nil, errors.New(errorMsg)
248252
}
249253
if !isGuiInitialized {
250254
fmt.Printf("Config file saved successfully to %s\n", path)

0 commit comments

Comments
 (0)