[ck2cti] Improve error messages associated with missing input files
This commit is contained in:
parent
da63482fea
commit
50344cb34f
2 changed files with 11 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue