From a9fcbc686d203b20f8e4b127e213b7028b3a9ae1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 8 Sep 2021 19:01:40 -0400 Subject: [PATCH] fix error when loading corrupted translation files --- docs/release-notes.md | 4 ++++ src/SMAPI/Framework/SCore.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 4e0a9df6..c04ac4e5 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,6 +1,10 @@ ← [README](README.md) # Release notes +## Upcoming release +* For players: + * Fixed crash loading mods if they have corrupted translation files. + ## 3.12.6 Released 03 September 2021 for Stardew Valley 1.5.4 or later. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 5913430e..df6cd129 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1891,9 +1891,9 @@ namespace StardewModdingAPI.Framework string locale = Path.GetFileNameWithoutExtension(file.Name.ToLower().Trim()); try { - if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary data)) + if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary data) || data == null) { - errors.Add($"{file.Name} file couldn't be read"); // should never happen, since we're iterating files that exist + errors.Add($"{file.Name} file couldn't be read"); // mainly happens when the file is corrupted or empty continue; }