Skip to content

Commit

Permalink
Adress issue #159 : keep logging enum parsing failures instead of swa…
Browse files Browse the repository at this point in the history
…llowing them silently.
  • Loading branch information
gotmachine committed Sep 12, 2023
1 parent 081c3bd commit ec6cc91
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions KSPCommunityFixes/Modding/PersistentIConfigNode.cs
Expand Up @@ -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:
Expand Down

0 comments on commit ec6cc91

Please sign in to comment.