Merge branch 'development' into prerequisites

This commit is contained in:
Robert committed 2021-04-26 23:13:23 +02:00
commit f1874d9fe3
2 files changed
+19 -19

No files matched your search

+16 -1
View File
@@ -148,8 +148,23 @@ namespace Artemis.Core.Services
foreach (ArtemisDevice device in toRemove)
RemoveDevice(device);
deviceProvider.Initialize(RGBDeviceType.All, true);
List<Exception> providerExceptions = new();
void DeviceProviderOnException(object? sender, ExceptionEventArgs e)
{
if (e.IsCritical)
providerExceptions.Add(e.Exception);
else
_logger.Warning(e.Exception, "Device provider {deviceProvider} threw non-critical exception", deviceProvider.GetType().Name);
}
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())
{