Skip to content

Commit cabcd54

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 a4f43cb commit cabcd54

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/config/app_config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ func migrateUserConfig(path string, content []byte, isGuiInitialized bool) ([]by
250250
fmt.Println(changesText)
251251
}
252252
if err := os.WriteFile(path, changedContent, 0o644); err != nil {
253-
return nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err)
253+
errorMsg := fmt.Sprintf("While attempting to write back migrated user config to %s, an error occurred: %s", path, err)
254+
if isGuiInitialized {
255+
errorMsg += "\n\n" + changesText
256+
}
257+
return nil, errors.New(errorMsg)
254258
}
255259
if !isGuiInitialized {
256260
fmt.Printf("Config file saved successfully to %s\n", path)

0 commit comments

Comments
 (0)