Skip to content

Commit

Permalink
Handle exception while editor is parsing custom layouts (#1430)
Browse files Browse the repository at this point in the history
* Fix migrating never applied custom zonesets

* Handle json parsing exception in LoadCustomModels()
  • Loading branch information
stefansjfw committed Mar 3, 2020
1 parent 121be77 commit 0199b4e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ public static ObservableCollection<LayoutModel> LoadCustomModels()
_customModels = new ObservableCollection<LayoutModel>();

FileStream inputStream = File.Open(Settings.CustomZoneSetsTmpFile, FileMode.Open);
var jsonObject = JsonDocument.Parse(inputStream, options: default);
JsonDocument jsonObject;
try
{
jsonObject = JsonDocument.Parse(inputStream, options: default);
}
catch
{
return _customModels;
}

JsonElement.ArrayEnumerator customZoneSetsEnumerator = jsonObject.RootElement.GetProperty("custom-zone-sets").EnumerateArray();
while (customZoneSetsEnumerator.MoveNext())
{
Expand Down

0 comments on commit 0199b4e

Please sign in to comment.