Skip to content

Commit a008448

Browse files
committed
Fix diffmodels.py exception handling for surface mechanisms.
When comparing mechanisms that are NOT surface models, it would do the load_chemkin_file as part of an `except` block, which then means if you get an error during `load_chemkin_file` the stack trace and error message are all confused and it looks like a KeyError: 'surface_path1' which is misleading.
1 parent ba3823b commit a008448

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

rmgpy/tools/diffmodels.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,16 @@ def execute(chemkin1, species_dict1, thermo1, chemkin2, species_dict2, thermo2,
361361
chemkin2 = chemkin_gas2
362362
kwargs['surface_path2'] = chemkin_surface2
363363

364-
try:
364+
if 'surface_path1' in kwargs and 'surface_path2' in kwargs:
365365
surface_path1 = kwargs['surface_path1']
366366
surface_path2 = kwargs['surface_path2']
367367
model1.species, model1.reactions = load_chemkin_file(
368368
chemkin1, species_dict1, thermo_path=thermo1, surface_path=surface_path1)
369369
model2.species, model2.reactions = load_chemkin_file(
370370
chemkin2, species_dict2, thermo_path=thermo2, surface_path=surface_path2)
371-
except KeyError:
372-
if 'surface_path1' in kwargs or 'surface_path2' in kwargs:
373-
logging.warning('Please specify 2 surface input files if you are comparing a surface mechanism')
374-
371+
elif 'surface_path1' in kwargs or 'surface_path2' in kwargs:
372+
raise ValueError('Please specify 2 surface input files if you are comparing a surface mechanism')
373+
else:
375374
model1.species, model1.reactions = load_chemkin_file(chemkin1, species_dict1, thermo_path=thermo1)
376375
model2.species, model2.reactions = load_chemkin_file(chemkin2, species_dict2, thermo_path=thermo2)
377376

0 commit comments

Comments
 (0)