Improve error when a mod adds duplicate translations
Pathoschild opened this issue ยท 1 comments
When a mod has duplicate translations, an ArgumentException
is thrown which doesn't provide any info about which mod failed:
[21:21:33 ERROR SMAPI] A mod failed handling the GameEvents.InitializeInternal event:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary
2..ctor(IDictionary2 dictionary, IEqualityComparer
1 comparer)
at StardewModdingAPI.Framework.ModHelpers.TranslationHelper.SetTranslations(IDictionary2 translations) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ModHelpers\TranslationHelper.cs:line 81 at StardewModdingAPI.Program.ReloadTranslations(IEnumerable
1 mods) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 998
at StardewModdingAPI.Program.LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 847
at StardewModdingAPI.Program.InitialiseAfterGameStart() in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 373
at StardewModdingAPI.Program.b__18_5(Object sender, EventArgs e) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 201
at StardewModdingAPI.Framework.InternalExtensions.SafelyRaisePlainEvent(IMonitor monitor, String name, IEnumerable`1 handlers, Object sender, EventArgs args) in C:\source_Stardew\SMAPI\src\SMAPI\Framework\InternalExtensions.cs:line 41
[21:21:33 TRACE SMAPI] Context: locale set to en.
Show a more friendly and informative error.