Skip to content

Commit

Permalink
Added safety checks for localization registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Nov 5, 2023
1 parent 485f5a3 commit fc6a9ea
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Nautilus/Handlers/LanguageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,22 @@ public static void RegisterLocalizationFolder(string languageFolderName = "Local

foreach (var file in Directory.GetFiles(path))
{
var content = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(file));
if (Path.GetExtension(file) != ".json")
{
continue;
}

// I hate this
Dictionary<string, string> content = null;
try
{
content = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(file));
}
catch (Exception e)
{
InternalLogger.Error($"Exception caught while trying to deserialize localization file at path: '{file}'. Exception: {e}");
}

if (content is null)
{
InternalLogger.Warn($"Localization file '{file}' is empty, skipping registration.");
Expand Down

0 comments on commit fc6a9ea

Please sign in to comment.