mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
[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
This commit is contained in:
@@ -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.
|
// 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)
|
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 to deserialize to the old format, which is presented in T2
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
T2 oldSettings = GetSettings<T2>(powertoy, fileName);
|
T2 oldSettings = GetSettings<T2>(powertoy, fileName);
|
||||||
T newSettings = (T)settingsUpgrader(oldSettings);
|
T newSettings = (T)settingsUpgrader(oldSettings);
|
||||||
|
Logger.LogInfo($"Settings file {fileName} for {powertoy} was read successfully in the old format.");
|
||||||
return newSettings;
|
return newSettings;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// do nothing, the problem wasn't that the settings was stored in the previous format, continue with the default settings
|
// 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)
|
catch (FileNotFoundException)
|
||||||
|
|||||||
Reference in New Issue
Block a user