Skip to content

Commit 3ff97e1

Browse files
committed
Fix Settings enumeration throwing exception
1 parent 6908a02 commit 3ff97e1

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/Atlasd/Daemon/Settings.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static JsonElement.ArrayEnumerator GetArray(string[] keyPath, bool suppre
6363
var json = State.RootElement;
6464
for (var i = 0; i < keyPath.Length; i++)
6565
{
66-
json.TryGetProperty(keyPath[i], out json);
66+
if (!json.TryGetProperty(keyPath[i], out json)) break;
6767
}
6868
return json.EnumerateArray();
6969
}
@@ -82,7 +82,7 @@ public static bool GetBoolean(string[] keyPath, bool defaultValue, bool suppress
8282
var json = State.RootElement;
8383
for (var i = 0; i < keyPath.Length; i++)
8484
{
85-
json.TryGetProperty(keyPath[i], out json);
85+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
8686
}
8787
return json.GetBoolean();
8888
}
@@ -101,7 +101,7 @@ public static byte GetByte(string[] keyPath, byte defaultValue, bool suppressLog
101101
var json = State.RootElement;
102102
for (var i = 0; i < keyPath.Length; i++)
103103
{
104-
json.TryGetProperty(keyPath[i], out json);
104+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
105105
}
106106
return json.GetByte();
107107
}
@@ -120,7 +120,7 @@ public static Int16 GetInt16(string[] keyPath, Int16 defaultValue, bool suppress
120120
var json = State.RootElement;
121121
for (var i = 0; i < keyPath.Length; i++)
122122
{
123-
json.TryGetProperty(keyPath[i], out json);
123+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
124124
}
125125
return json.GetInt16();
126126
}
@@ -139,7 +139,7 @@ public static Int32 GetInt32(string[] keyPath, Int32 defaultValue, bool suppress
139139
var json = State.RootElement;
140140
for (var i = 0; i < keyPath.Length; i++)
141141
{
142-
json.TryGetProperty(keyPath[i], out json);
142+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
143143
}
144144
return json.GetInt32();
145145
}
@@ -158,7 +158,7 @@ public static Int64 GetInt64(string[] keyPath, Int64 defaultValue, bool suppress
158158
var json = State.RootElement;
159159
for (var i = 0; i < keyPath.Length; i++)
160160
{
161-
json.TryGetProperty(keyPath[i], out json);
161+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
162162
}
163163
return json.GetInt64();
164164
}
@@ -177,7 +177,7 @@ public static sbyte GetSByte(string[] keyPath, sbyte defaultValue, bool suppress
177177
var json = State.RootElement;
178178
for (var i = 0; i < keyPath.Length; i++)
179179
{
180-
json.TryGetProperty(keyPath[i], out json);
180+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
181181
}
182182
return json.GetSByte();
183183
}
@@ -196,7 +196,7 @@ public static string GetString(string[] keyPath, string defaultValue, bool suppr
196196
var json = State.RootElement;
197197
for (var i = 0; i < keyPath.Length; i++)
198198
{
199-
json.TryGetProperty(keyPath[i], out json);
199+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
200200
}
201201
return json.GetString();
202202
}
@@ -215,7 +215,7 @@ public static UInt16 GetUInt16(string[] keyPath, UInt16 defaultValue, bool suppr
215215
var json = State.RootElement;
216216
for (var i = 0; i < keyPath.Length; i++)
217217
{
218-
json.TryGetProperty(keyPath[i], out json);
218+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
219219
}
220220
return json.GetUInt16();
221221
}
@@ -234,7 +234,7 @@ public static UInt32 GetUInt32(string[] keyPath, UInt32 defaultValue, bool suppr
234234
var json = State.RootElement;
235235
for (var i = 0; i < keyPath.Length; i++)
236236
{
237-
json.TryGetProperty(keyPath[i], out json);
237+
if (!json.TryGetProperty(keyPath[i], out json)) return defaultValue;
238238
}
239239
return json.GetUInt32();
240240
}

0 commit comments

Comments
 (0)