Skip to content

Commit

Permalink
more null handling hijinks
Browse files Browse the repository at this point in the history
  • Loading branch information
tg359 authored and Fraser Greenroyd committed Dec 1, 2022
1 parent 2ba80e5 commit 66f7a44
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions LadybugTools_Engine/Compute/EPWtoCSV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions LadybugTools_Engine/Compute/EPWtoCustomObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions LadybugTools_Engine/Compute/ExternalComfort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions LadybugTools_Engine/Compute/GEMtoHBJSON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions LadybugTools_Engine/Compute/HBJSONtoGEM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions LadybugTools_Engine/Compute/SimulationId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 5 additions & 1 deletion LadybugTools_Engine/Compute/SimulationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66f7a44

Please sign in to comment.