stop using exceptions for flow control

This commit is contained in:
zeromus 2021-03-28 15:24:28 -04:00
parent 99c8e4e910
commit 23c0928107
1 changed files with 11 additions and 4 deletions

View File

@ -138,20 +138,27 @@ namespace BizHawk.Client.EmuHawk
var requestedExtToolDll = _argParser.openExtToolDll;
if (requestedExtToolDll != null)
{
IExternalToolForm loaded = null;
var enabled = ExtToolManager.ToolStripMenu.Where(item => item.Enabled)
.Select(item => ((string, string)) item.Tag)
.ToList();
try
{
var found = enabled.First(tuple => tuple.Item1 == requestedExtToolDll
int foundIndex = enabled.FindIndex(tuple =>
tuple.Item1 == requestedExtToolDll
|| Path.GetFileName(tuple.Item1) == requestedExtToolDll
|| Path.GetFileNameWithoutExtension(tuple.Item1) == requestedExtToolDll);
Tools.LoadExternalToolForm(found.Item1, found.Item2, skipExtToolWarning: true);
if(foundIndex != -1)
loaded = Tools.LoadExternalToolForm(enabled[foundIndex].Item1, enabled[foundIndex].Item2, skipExtToolWarning: true);
}
catch (Exception)
catch
{
Console.WriteLine($"requested ext. tool dll {requestedExtToolDll} could not be loaded");
}
if(loaded == null)
Console.WriteLine($"requested ext. tool dll {requestedExtToolDll} could not be loaded");
}
}