Improve error message in `Bk2LogEntryGenerator` ctor (see #3704)

This commit is contained in:
James Groom 2023-12-13 07:50:16 +10:00 committed by GitHub
parent 3bcc6ee977
commit 8a806c897d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -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})");
}
}
}