From 4f6b44ba3a722ebda2247ce1a545d96cd1a0dfb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:26:20 +0000 Subject: [PATCH 1/3] Initial plan From 41ed2511f5da4c0ad48e02d7afeadb81d9ef3cd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:33:52 +0000 Subject: [PATCH 2/3] Fix misleading log message when device factory throws an exception --- .../Factory/DeviceFactory.cs | 54 +++++++++---------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs index c79be592a..c551bc734 100644 --- a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs @@ -188,48 +188,42 @@ private static string GetSecret(SecretsPropertiesConfig data) /// /// This method attempts to create a device using the type specified in the /// parameter. If the type corresponds to a registered factory method, the device is created and returned. If the - /// type is unrecognized or an exception occurs, the method logs the error and returns . + /// type is unrecognized, the method logs a warning and returns . If the factory method + /// throws an exception while creating the device, that exception is allowed to propagate to the caller so that + /// the real cause of the failure can be reported, rather than being masked as an unknown device type. /// The configuration object containing the key, name, type, and properties required to create the device. /// An instance of a device that implements , or if the device type is - /// not recognized or an error occurs during creation. + /// not recognized. + /// Thrown when the registered factory method for the device type throws an exception while creating the + /// device. Callers should catch and log this exception to report the actual cause of the failure. public static IKeyed GetDevice(DeviceConfig dc) { - try - { - var localDc = new DeviceConfig(dc); - - var key = localDc.Key; - var name = localDc.Name; - var type = localDc.Type; - var properties = localDc.Properties; - - var typeName = localDc.Type.ToLower(); + var localDc = new DeviceConfig(dc); - if (properties is JObject jObject) - { - var jProp = jObject.Properties(); - - CheckForSecrets(jProp); - } + var properties = localDc.Properties; - if (!FactoryMethods.TryGetValue(typeName, out var wrapper)) - { - Debug.LogWarning("Device type '{typeName}' not found in DeviceFactory", typeName); - return null; - } + var typeName = localDc.Type.ToLower(); - Debug.LogInformation("Loading '{type}' from {assemblyName}", typeName, wrapper.Type.Assembly.FullName); + if (properties is JObject jObject) + { + var jProp = jObject.Properties(); - // Check for types that have been added by plugin dlls. - return wrapper.FactoryMethod(localDc); + CheckForSecrets(jProp); } - catch (Exception ex) + + if (!FactoryMethods.TryGetValue(typeName, out var wrapper)) { - Debug.LogError(ex, "Exception occurred while creating device {key}: {message}", dc.Key, ex.Message); - Debug.LogDebug(ex, "Exception details: {stackTrace}", ex.StackTrace); + Debug.LogWarning("Device type '{typeName}' not found in DeviceFactory", typeName); return null; } + + Debug.LogInformation("Loading '{type}' from {assemblyName}", typeName, wrapper.Type.Assembly.FullName); + + // Check for types that have been added by plugin dlls. + // Any exception thrown by the factory method is intentionally not caught here, so that it + // propagates to the caller and can be logged with the real cause of the failure, rather than + // being reported as an unknown device type. + return wrapper.FactoryMethod(localDc); } /// From e621a2046abec1ee0ed0c3dcf10adb5e956c052b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Jul 2026 17:39:23 +0000 Subject: [PATCH 3/3] chore: trigger build