From 66f7a44e23ffa2ad05dbe9af1e3421e1026acf2f Mon Sep 17 00:00:00 2001 From: Tristan Gerrish Date: Wed, 30 Nov 2022 16:06:04 +0000 Subject: [PATCH] more null handling hijinks --- LadybugTools_Engine/Compute/EPWtoCSV.cs | 2 ++ LadybugTools_Engine/Compute/EPWtoCustomObject.cs | 2 ++ LadybugTools_Engine/Compute/ExternalComfort.cs | 2 ++ LadybugTools_Engine/Compute/GEMtoHBJSON.cs | 2 ++ LadybugTools_Engine/Compute/HBJSONtoGEM.cs | 2 ++ LadybugTools_Engine/Compute/SimulationId.cs | 4 ++++ LadybugTools_Engine/Compute/SimulationResult.cs | 6 +++++- 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/LadybugTools_Engine/Compute/EPWtoCSV.cs b/LadybugTools_Engine/Compute/EPWtoCSV.cs index 7a082153..a8b61c97 100644 --- a/LadybugTools_Engine/Compute/EPWtoCSV.cs +++ b/LadybugTools_Engine/Compute/EPWtoCSV.cs @@ -39,11 +39,13 @@ public static string EPWtoCSV(string epwFile) if (epwFile == null) { BH.Engine.Base.Compute.RecordError("epwFile input cannot be null."); + return null; } if (!System.IO.File.Exists(epwFile)) { BH.Engine.Base.Compute.RecordError($"{epwFile} doesn't appear to exist!"); + return null; } BH.oM.Python.PythonEnvironment env = Compute.InstallPythonEnv_LBT(true); diff --git a/LadybugTools_Engine/Compute/EPWtoCustomObject.cs b/LadybugTools_Engine/Compute/EPWtoCustomObject.cs index 13d01aac..264fb29b 100644 --- a/LadybugTools_Engine/Compute/EPWtoCustomObject.cs +++ b/LadybugTools_Engine/Compute/EPWtoCustomObject.cs @@ -41,11 +41,13 @@ public static CustomObject EPWtoCustomObject(string epwFile) if (epwFile == null) { BH.Engine.Base.Compute.RecordError("epwFile input cannot be null."); + return null; } if (!System.IO.File.Exists(epwFile)) { BH.Engine.Base.Compute.RecordError($"{epwFile} doesn't appear to exist!"); + return null; } BH.oM.Python.PythonEnvironment env = Compute.InstallPythonEnv_LBT(true); diff --git a/LadybugTools_Engine/Compute/ExternalComfort.cs b/LadybugTools_Engine/Compute/ExternalComfort.cs index a06e5837..bf483b42 100644 --- a/LadybugTools_Engine/Compute/ExternalComfort.cs +++ b/LadybugTools_Engine/Compute/ExternalComfort.cs @@ -46,11 +46,13 @@ public static ExternalComfort ExternalComfort(SimulationResult simulationResult, if (simulationResult == null) { BH.Engine.Base.Compute.RecordError("simulationResult input cannot be null."); + return null; } if (typology == null) { BH.Engine.Base.Compute.RecordError("typology input cannot be null."); + return null; } // construct the base object diff --git a/LadybugTools_Engine/Compute/GEMtoHBJSON.cs b/LadybugTools_Engine/Compute/GEMtoHBJSON.cs index 1789dab7..b5b9eea1 100644 --- a/LadybugTools_Engine/Compute/GEMtoHBJSON.cs +++ b/LadybugTools_Engine/Compute/GEMtoHBJSON.cs @@ -39,11 +39,13 @@ public static string GEMtoHBJSON(string gem) if (gem == null) { BH.Engine.Base.Compute.RecordError("gem input cannot be null."); + return null; } if (!System.IO.File.Exists(gem)) { BH.Engine.Base.Compute.RecordError($"{gem} doesn't appear to exist!"); + return null; } BH.oM.Python.PythonEnvironment env = Compute.InstallPythonEnv_LBT(true); diff --git a/LadybugTools_Engine/Compute/HBJSONtoGEM.cs b/LadybugTools_Engine/Compute/HBJSONtoGEM.cs index 90e10edd..79944b9c 100644 --- a/LadybugTools_Engine/Compute/HBJSONtoGEM.cs +++ b/LadybugTools_Engine/Compute/HBJSONtoGEM.cs @@ -39,11 +39,13 @@ public static string HBJSONtoGEM(string hbjson) if (hbjson == null) { BH.Engine.Base.Compute.RecordError("hbjson input cannot be null."); + return null; } if (!System.IO.File.Exists(hbjson)) { BH.Engine.Base.Compute.RecordError($"{hbjson} doesn't appear to exist!"); + return null; } BH.oM.Python.PythonEnvironment env = Compute.InstallPythonEnv_LBT(true); diff --git a/LadybugTools_Engine/Compute/SimulationId.cs b/LadybugTools_Engine/Compute/SimulationId.cs index df8abeec..c4f6da1d 100644 --- a/LadybugTools_Engine/Compute/SimulationId.cs +++ b/LadybugTools_Engine/Compute/SimulationId.cs @@ -41,21 +41,25 @@ public static string SimulationId(string epwFile, ILBTMaterial groundMaterial, I if (epwFile == null) { BH.Engine.Base.Compute.RecordError("epwFile input cannot be null."); + return null; } if (groundMaterial == null) { BH.Engine.Base.Compute.RecordError("groundMaterial input cannot be null."); + return null; } if (shadeMaterial == null) { BH.Engine.Base.Compute.RecordError("shadeMaterial input cannot be null."); + return null; } if (!System.IO.File.Exists(epwFile)) { BH.Engine.Base.Compute.RecordError($"{epwFile} doesn't appear to exist!"); + return null; } string epwId = Convert.SanitiseString(Path.GetFileNameWithoutExtension(epwFile)); diff --git a/LadybugTools_Engine/Compute/SimulationResult.cs b/LadybugTools_Engine/Compute/SimulationResult.cs index 471eb597..5c98fa28 100644 --- a/LadybugTools_Engine/Compute/SimulationResult.cs +++ b/LadybugTools_Engine/Compute/SimulationResult.cs @@ -46,21 +46,25 @@ public static SimulationResult SimulationResult(string epwFile, ILBTMaterial gro if (epwFile == null) { BH.Engine.Base.Compute.RecordError("epwFile input cannot be null."); + return null; } if (groundMaterial == null) { - BH.Engine.Base.Compute.RecordError("groundMaterial) input cannot be null."); + BH.Engine.Base.Compute.RecordError("groundMaterial input cannot be null."); + return null; } if (shadeMaterial == null) { BH.Engine.Base.Compute.RecordError("shadeMaterial input cannot be null."); + return null; } if (!System.IO.File.Exists(epwFile)) { BH.Engine.Base.Compute.RecordError($"{epwFile} doesn't appear to exist!"); + return null; } // construct the base object