Skip to content

Commit 71e0f74

Browse files
author
marc
committed
Add try catch
1 parent 320016c commit 71e0f74

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Src/StackifyLib/Config.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,26 @@ internal static string Get(string key, string defaultValue = null)
204204

205205
public static void ReadStackifyJSONConfig(string filePath)
206206
{
207-
string json;
208-
209-
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
207+
try
210208
{
211-
using (var sr = new StreamReader(fs))
209+
string json;
210+
211+
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
212212
{
213-
json = sr.ReadToEnd();
213+
using (var sr = new StreamReader(fs))
214+
{
215+
json = sr.ReadToEnd();
216+
}
214217
}
215-
}
216218

217-
var obj = JObject.Parse(json, Settings);
218-
Config.SetStackifyObj(obj);
219+
var obj = JObject.Parse(json, Settings);
220+
Config.SetStackifyObj(obj);
221+
}
222+
catch (Exception ex)
223+
{
224+
StackifyAPILogger.Log("#Config #ReadStackifyJSONConfig failed", ex);
225+
}
226+
219227
}
220228

221229
public static void SetStackifyObj(JObject obj)

0 commit comments

Comments
 (0)