From ba9e2449f3d634b5c0908a0c8c616a3c967019e1 Mon Sep 17 00:00:00 2001 From: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:52:43 +0100 Subject: [PATCH] [Settings]Better logging when upgrading settings from a old format (#22497) * SettingUtils fixing error reporting when reading settings in old format * Making the error message even more informative --- src/settings-ui/Settings.UI.Library/SettingsUtils.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/settings-ui/Settings.UI.Library/SettingsUtils.cs b/src/settings-ui/Settings.UI.Library/SettingsUtils.cs index d4d803cd17..e68a967a89 100644 --- a/src/settings-ui/Settings.UI.Library/SettingsUtils.cs +++ b/src/settings-ui/Settings.UI.Library/SettingsUtils.cs @@ -115,18 +115,20 @@ namespace Microsoft.PowerToys.Settings.UI.Library // This is different from the case where we have trailing zeros following a valid json file, which we have handled by trimming the trailing zeros. catch (JsonException ex) { - Logger.LogError($"Exception encountered while loading {powertoy} settings.", ex); + Logger.LogInfo($"Settings file {fileName} for {powertoy} was unrecognized. Possibly containing an older version. Trying to read again."); // try to deserialize to the old format, which is presented in T2 try { T2 oldSettings = GetSettings(powertoy, fileName); T newSettings = (T)settingsUpgrader(oldSettings); + Logger.LogInfo($"Settings file {fileName} for {powertoy} was read successfully in the old format."); return newSettings; } catch (Exception) { // do nothing, the problem wasn't that the settings was stored in the previous format, continue with the default settings + Logger.LogError($"{powertoy} settings are corrupt or the format is not supported any longer. Using default settings instead.", ex); } } catch (FileNotFoundException)