From 8ee538851f389503f53e69f81bbbcc39530a0b67 Mon Sep 17 00:00:00 2001 From: iht Date: Wed, 22 Jan 2025 00:43:23 +0100 Subject: [PATCH] Fix KeyNotFoundException --- ImperatorToCK3/CK3/Religions/Faith.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ImperatorToCK3/CK3/Religions/Faith.cs b/ImperatorToCK3/CK3/Religions/Faith.cs index 7845513dd..62cbaa3fb 100644 --- a/ImperatorToCK3/CK3/Religions/Faith.cs +++ b/ImperatorToCK3/CK3/Religions/Faith.cs @@ -93,7 +93,11 @@ public string Serialize(string indent, bool withBraces) { } public OrderedSet GetDoctrineIdsForDoctrineCategoryId(string doctrineCategoryId) { - var category = Religion.ReligionCollection.DoctrineCategories[doctrineCategoryId]; + if (!Religion.ReligionCollection.DoctrineCategories.TryGetValue(doctrineCategoryId, out var category)) { + Logger.Warn($"Doctrine category {doctrineCategoryId} not found."); + return []; + } + return GetDoctrineIdsForDoctrineCategory(category); }