diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs index 26c66ed54..50f2d05b8 100644 --- a/src/Artemis.Core/Services/RgbService.cs +++ b/src/Artemis.Core/Services/RgbService.cs @@ -148,8 +148,17 @@ namespace Artemis.Core.Services foreach (ArtemisDevice device in toRemove) RemoveDevice(device); - deviceProvider.Initialize(RGBDeviceType.All, true); + List providerExceptions = new(); + void DeviceProviderOnException(object? sender, Exception e) => providerExceptions.Add(e); + + deviceProvider.Exception += DeviceProviderOnException; + deviceProvider.Initialize(); Surface.Attach(deviceProvider.Devices); + deviceProvider.Exception -= DeviceProviderOnException; + if (providerExceptions.Count == 1) + throw new ArtemisPluginException("RGB.NET threw exception: " + providerExceptions.First().Message, providerExceptions.First()); + if (providerExceptions.Count > 1) + throw new ArtemisPluginException("RGB.NET threw multiple exceptions", new AggregateException(providerExceptions)); if (!deviceProvider.Devices.Any()) {