From 3493f27b6f72316c96f6ec09d84352c4d227799f Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 10 Sep 2021 13:25:26 +0100 Subject: [PATCH] Check input files exist, exit gracefully if they dont --- QuestValidator.Common/Helpers/QuestHelper.cs | 10 ++++++++++ QuestValidator/Program.cs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/QuestValidator.Common/Helpers/QuestHelper.cs b/QuestValidator.Common/Helpers/QuestHelper.cs index 96d524e..71234e3 100644 --- a/QuestValidator.Common/Helpers/QuestHelper.cs +++ b/QuestValidator.Common/Helpers/QuestHelper.cs @@ -244,6 +244,11 @@ namespace AssortGenerator.Common.Helpers if (_questData == null) { var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename)); + if (questFilePath == null) + { + return null; + } + var questDataJson = File.ReadAllText(questFilePath); _questData = JsonSerializer.Deserialize>(questDataJson); } @@ -256,6 +261,11 @@ namespace AssortGenerator.Common.Helpers if (_liveQuestData == null) { var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename)); + if (questFilePath == null) + { + return null; + } + var questDataJson = File.ReadAllText(questFilePath); _liveQuestData = JsonSerializer.Deserialize(questDataJson); } diff --git a/QuestValidator/Program.cs b/QuestValidator/Program.cs index dd7e1e0..226d47f 100644 --- a/QuestValidator/Program.cs +++ b/QuestValidator/Program.cs @@ -20,6 +20,12 @@ namespace QuestValidator var questData = QuestHelper.GetQuestData(); var liveQuestData = QuestHelper.GetLiveQuestData(); + if (questData == null || liveQuestData == null) + { + LoggingHelpers.LogError("Unable to read quest data. Are you sure the both quest files are in 'QuestValidator//bin//Debug//netcoreapp3.1//input'"); + return; + } + CheckForMissingQuestsInAkiFile(liveQuestData, questData); foreach (var item in questData)