From ec6cc918ba48f8886258be85835cc16ba9a130f6 Mon Sep 17 00:00:00 2001 From: gotmachine <24925209+gotmachine@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:24:09 +0200 Subject: [PATCH] Adress issue #159 : keep logging enum parsing failures instead of swallowing them silently. --- KSPCommunityFixes/Modding/PersistentIConfigNode.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs index fdaace9..67cb25c 100644 --- a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs +++ b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs @@ -629,6 +629,9 @@ public static object ReadValue(string value, DataType dataType, Type fieldType) } catch { + string[] enumNames = fieldType.GetEnumNames(); + string defaultName = enumNames.Length > 0 ? enumNames[0] : string.Empty; + Debug.LogWarning($"[KSPCF] Couldn't parse value '{value}' for enum '{fieldType.Name}', default value '{defaultName}' will be used.\nValid values are {string.Join(", ", enumNames)}"); return null; } case DataType.ValueVector2: