From 50344cb34f89d25c440218e08d4f8f33a33fa0ba Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 27 Mar 2014 01:29:50 +0000 Subject: [PATCH] [ck2cti] Improve error messages associated with missing input files --- interfaces/cython/cantera/ck2cti.py | 6 ++++++ test/thermo/phaseConstructors.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index f5494491b..dcdc1eb81 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -1807,6 +1807,8 @@ duplicate transport data) to be ignored. if permissive is not None: self.warning_as_error = not permissive + if not os.path.exists(inputFile): + raise IOError('Missing input file: {0!r}'.format(inputFile)) try: # Read input mechanism files self.loadChemkinFile(inputFile) @@ -1816,6 +1818,8 @@ duplicate transport data) to be ignored. raise if thermoFile: + if not os.path.exists(thermoFile): + raise IOError('Missing thermo file: {0!r}'.format(thermoFile)) try: self.loadChemkinFile(thermoFile) except Exception: @@ -1824,6 +1828,8 @@ duplicate transport data) to be ignored. raise if transportFile: + if not os.path.exists(transportFile): + raise IOError('Missing transport file: {0!r}'.format(transportFile)) lines = [strip_nonascii(line) for line in open(transportFile, 'rU')] self.parseTransportData(lines) diff --git a/test/thermo/phaseConstructors.cpp b/test/thermo/phaseConstructors.cpp index 949ae75fc..74081f0ac 100644 --- a/test/thermo/phaseConstructors.cpp +++ b/test/thermo/phaseConstructors.cpp @@ -80,6 +80,11 @@ TEST_F(ChemkinConversionTest, ValidConversion) { ASSERT_GT(p->temperature(), 0.0); } +TEST_F(ChemkinConversionTest, MissingInputFile) { + ASSERT_THROW(ctml::ck2cti("nonexistent-file.inp"), + CanteraError); +} + TEST_F(ChemkinConversionTest, FailedConversion) { copyInputFile("h2o2_missingThermo.inp"); ASSERT_THROW(ctml::ck2cti("h2o2_missingThermo.inp"),