Skip to content

Commit e629d08

Browse files
authored
[Windows] Catch COMException on load (#468)
1 parent 816c372 commit e629d08

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

windows/QMK Toolbox/MainWindow.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.IO;
1313
using System.Linq;
1414
using System.Net.Http;
15+
using System.Runtime.InteropServices;
1516
using System.Windows.Forms;
1617

1718
namespace QMK_Toolbox
@@ -81,7 +82,16 @@ private void MainWindow_Load(object sender, EventArgs e)
8182
usbListener.bootloaderDeviceConnected += BootloaderDeviceConnected;
8283
usbListener.bootloaderDeviceDisconnected += BootloaderDeviceDisconnected;
8384
usbListener.outputReceived += BootloaderCommandOutputReceived;
84-
usbListener.Start();
85+
86+
try
87+
{
88+
usbListener.Start();
89+
}
90+
catch (COMException ex)
91+
{
92+
logTextBox.LogError("USB device enumeration failed.");
93+
logTextBox.LogError($"{ex}");
94+
}
8595

8696
if (_filePassedIn != string.Empty)
8797
{

0 commit comments

Comments
 (0)