From 8a806c897db6a62d1f6d64610b5b98b5ac8d8b8c Mon Sep 17 00:00:00 2001 From: James Groom Date: Wed, 13 Dec 2023 07:50:16 +1000 Subject: [PATCH] Improve error message in `Bk2LogEntryGenerator` ctor (see #3704) --- .../movie/bk2/Bk2LogEntryGenerator.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index 7b5d10ea3f..3814099187 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -20,11 +21,16 @@ namespace BizHawk.Client.Common _systemId = systemId; _source = source; _controlsOrdered = _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0).ToList(); - foreach (var group in _controlsOrdered) + foreach (var group in _controlsOrdered) foreach (var button in group) { - foreach (var button in group) + var found = Bk2MnemonicLookup.Lookup(button, _systemId); + try { - _mnemonics.Add(button, Bk2MnemonicLookup.Lookup(button, _systemId)); + _mnemonics.Add(button, found); + } + catch (ArgumentException e) + { + throw new ArgumentException(innerException: e, paramName: nameof(source), message: $"duplicate KEY {button} in input log mnemonic cache (was {_mnemonics[button]}, attempting to set {found})"); } } }