Browse Source

Extended the try block in Load to make it behave well when the file exists but is empty

pull/44/head
Anairkoen Schno 4 years ago
parent
commit
4e36470060
1 changed files with 10 additions and 10 deletions
  1. +10
    -10
      IPA.Loader/Config/Providers/JsonConfigProvider.cs

+ 10
- 10
IPA.Loader/Config/Providers/JsonConfigProvider.cs View File

@ -24,17 +24,17 @@ namespace IPA.Config.Providers
public Value Load(FileInfo file) public Value Load(FileInfo file)
{ {
if (!file.Exists) return Value.Null();
JToken jtok;
using (var sreader = new StreamReader(file.OpenRead()))
{
using var jreader = new JsonTextReader(sreader);
jtok = JToken.ReadFrom(jreader);
}
if (!file.Exists) return Value.Null();
try try
{
{
JToken jtok;
using (var sreader = new StreamReader(file.OpenRead()))
{
using var jreader = new JsonTextReader(sreader);
jtok = JToken.ReadFrom(jreader);
}
return VisitToValue(jtok); return VisitToValue(jtok);
} }
catch (Exception e) catch (Exception e)


Loading…
Cancel
Save