From ac40a93ef1728a777eb1d7855695c851e7e1e8bb Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Fri, 31 Oct 2025 13:07:52 +0100 Subject: [PATCH] Simplify child registration error handling --- src/specificClass.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/specificClass.js b/src/specificClass.js index aba5570..f1d8123 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -79,6 +79,11 @@ class Machine { /*------------------- Register child events -------------------*/ registerChild(child, softwareType) { + if(!child) { + this.logger.error(`Invalid ${softwareType} child provided.`); + return; + } + switch (softwareType) { case "measurement": this.logger.debug(`Registering measurement child...`); @@ -95,11 +100,6 @@ class Machine { } _connectMeasurement(measurementChild) { - if (!measurementChild) { - this.logger.error("Invalid measurement provided."); - return; - } - const position = measurementChild.config.functionality.positionVsParent; const distance = measurementChild.config.functionality.distanceVsParent || 0; const measurementType = measurementChild.config.asset.type; @@ -137,11 +137,6 @@ class Machine { } _connectReactor(reactorChild) { - if (!reactorChild) { - this.logger.error("Invalid measurement provided."); - return; - } - this.downstreamReactor = reactorChild; // downstream from the pumps perpective }