Skip to content

Commit 66a6ca7

Browse files
committed
Fix: Minor improvements
1 parent 85952da commit 66a6ca7

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

Source/NETworkManager.Settings/LocalSettingsManager.cs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,19 @@ public static void Load()
9999
}
100100
else
101101
{
102-
Current = JsonSerializer.Deserialize<LocalSettingsInfo>(jsonString, JsonOptions);
103-
104-
// Check if deserialization returned null (e.g., file contains "null")
105-
if (Current == null)
106-
{
107-
Log.Warn("Local settings deserialized to null, initializing new local settings.");
108-
}
109-
else
110-
{
111-
Log.Info("Local settings loaded successfully.");
112-
113-
// Reset change tracking
114-
Current.SettingsChanged = false;
115-
116-
return;
117-
}
102+
Current = JsonSerializer.Deserialize<LocalSettingsInfo>(jsonString, JsonOptions) ?? new LocalSettingsInfo();
103+
104+
Log.Info("Local settings loaded successfully.");
105+
106+
// Reset change tracking
107+
Current.SettingsChanged = false;
108+
109+
return;
118110
}
119111
}
120112
catch (Exception ex)
121113
{
122-
{
123-
Log.Error($"Failed to load local settings from: {filePath}", ex);
124-
}
114+
Log.Error($"Failed to load local settings from: {filePath}", ex);
125115
}
126116
}
127117

Source/NETworkManager/App.xaml.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,7 @@ by BornToBeRoot
8787
PolicyManager.Load();
8888

8989
// Load (or initialize) local settings
90-
try
91-
{
92-
LocalSettingsManager.Load();
93-
}
94-
catch (IOException ex)
95-
{
96-
Log.Error("Could not load local settings due to an I/O error! Using default local settings.", ex);
97-
}
98-
catch (UnauthorizedAccessException ex)
99-
{
100-
Log.Error("Could not load local settings due to insufficient permissions! Using default local settings.", ex);
101-
}
102-
catch (JsonException ex)
103-
{
104-
Log.Error("Could not load local settings! Local settings JSON is corrupted or invalid. Using default local settings.", ex);
105-
}
90+
LocalSettingsManager.Load();
10691

10792
// Load (or initialize) settings
10893
try

0 commit comments

Comments
 (0)