Check input files exist, exit gracefully if they dont

This commit is contained in:
Chomp 2021-09-10 13:25:26 +01:00
parent 56fbe22591
commit 3493f27b6f
2 changed files with 16 additions and 0 deletions

View File

@ -244,6 +244,11 @@ namespace AssortGenerator.Common.Helpers
if (_questData == null) if (_questData == null)
{ {
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename)); var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename));
if (questFilePath == null)
{
return null;
}
var questDataJson = File.ReadAllText(questFilePath); var questDataJson = File.ReadAllText(questFilePath);
_questData = JsonSerializer.Deserialize<Dictionary<string, Quest>>(questDataJson); _questData = JsonSerializer.Deserialize<Dictionary<string, Quest>>(questDataJson);
} }
@ -256,6 +261,11 @@ namespace AssortGenerator.Common.Helpers
if (_liveQuestData == null) if (_liveQuestData == null)
{ {
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename)); var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename));
if (questFilePath == null)
{
return null;
}
var questDataJson = File.ReadAllText(questFilePath); var questDataJson = File.ReadAllText(questFilePath);
_liveQuestData = JsonSerializer.Deserialize<QuestRoot>(questDataJson); _liveQuestData = JsonSerializer.Deserialize<QuestRoot>(questDataJson);
} }

View File

@ -20,6 +20,12 @@ namespace QuestValidator
var questData = QuestHelper.GetQuestData(); var questData = QuestHelper.GetQuestData();
var liveQuestData = QuestHelper.GetLiveQuestData(); 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); CheckForMissingQuestsInAkiFile(liveQuestData, questData);
foreach (var item in questData) foreach (var item in questData)