From a3cf2414475b0f4c065a4295829099f6222d488a Mon Sep 17 00:00:00 2001 From: Peter Andrews Date: Mon, 11 Mar 2019 23:38:18 +0000 Subject: [PATCH] Issue #221 throw an exception if coefficients path not a valid file --- .../ChoiceModels/ChoiceProbabilityFactory.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DaySim.Framework/ChoiceModels/ChoiceProbabilityFactory.cs b/DaySim.Framework/ChoiceModels/ChoiceProbabilityFactory.cs index aa75e387..060c2f1d 100644 --- a/DaySim.Framework/ChoiceModels/ChoiceProbabilityFactory.cs +++ b/DaySim.Framework/ChoiceModels/ChoiceProbabilityFactory.cs @@ -6,6 +6,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +using System; using System.IO; using DaySim.Framework.Coefficients; @@ -33,13 +34,12 @@ public sealed class ChoiceProbabilityFactory { if (file.Exists) { coefficientsReader = new CoefficientsReader(); - + } else { + string message = string.Format("No file exists at coefficientsPath '{0}'", coefficientsPath); + DaySim.Framework.Core.Global.PrintFile.WriteLine(message, true); + throw new Exception(message); } } - if (coefficientsReader == null) { - - } - if (coefficientsReader != null) { _coefficients = coefficientsReader.Read(coefficientsPath, out _title, out _sizeFunctionMultiplier, @@ -70,4 +70,4 @@ public sealed class ChoiceProbabilityFactory { return choiceProbabilityCalculator; } } -} \ No newline at end of file +}