diff --git a/interfaces/cython/cantera/ck2yaml.py b/interfaces/cython/cantera/ck2yaml.py index 109fa875b4..e62194700d 100644 --- a/interfaces/cython/cantera/ck2yaml.py +++ b/interfaces/cython/cantera/ck2yaml.py @@ -164,6 +164,9 @@ class InputError(Exception): the exceptional behavior. """ def __init__(self, message, *args, **kwargs): + message += ("\nPlease check https://cantera.org/tutorials/" + "ck2yaml-tutorial.html#debugging-common-errors-in-ck-files" + "\nfor the correct Chemkin syntax.") if args or kwargs: super().__init__(message.format(*args, **kwargs)) else: @@ -688,8 +691,7 @@ def __init__(self, label, geometry, well_depth, collision_diameter, "Bad geometry flag '{}' for species '{}', is the flag a float " "or character? It should be an integer.", geometry, label) if geometry not in (0, 1, 2): - raise InputError("Bad geometry flag '{}' for species '{}'", - geometry, label) + raise InputError("Bad geometry flag '{}' for species '{}'.", geometry, label) self.geometry = self.geometry_flags[int(geometry)] self.well_depth = float(well_depth) @@ -885,7 +887,7 @@ def read_NASA7_entry(self, lines, TintDefault, comments): if not composition: raise InputError("Error parsing elemental composition for " - "species '{}'", species) + "species '{}'.", species) for symbol in composition.keys(): # Some CHEMKIN input files may have quantities of elements with @@ -894,8 +896,8 @@ def read_NASA7_entry(self, lines, TintDefault, comments): # more useful error message. if any(map(str.isdigit, symbol)) and symbol not in self.elements: raise InputError("Error parsing elemental composition for " - "species thermo entry:\n{}\nElement amounts" - "can have no more than 3 digits", + "species thermo entry:\n{}\nElement amounts " + "can have no more than 3 digits.", "".join(lines)) # Extract the NASA polynomial coefficients @@ -965,7 +967,7 @@ def read_NASA9_entry(self, entry, comments): fortFloat(C[64:80])] polys.append((Trange, coeffs)) except (IndexError, ValueError) as err: - raise InputError('Error while reading thermo entry for species {}:\n{}', + raise InputError('Error while reading thermo entry for species {}:\n{}.', species, err) thermo = Nasa9(data=polys, note=note) @@ -1315,7 +1317,7 @@ def parse_expression(expression, dest): surface] if sum(bool(t) for t in tests) > 1: raise InputError('Reaction {} contains parameters for more than ' - 'one reaction type.', original_reaction) + 'one reaction type.', original_reaction) if cheb_coeffs: if Tmin is None or Tmax is None: @@ -1354,7 +1356,7 @@ def parse_expression(expression, dest): elif reaction.third_body: raise InputError('Reaction equation implies pressure ' 'dependence but no alternate rate parameters (i.e. HIGH or ' - 'LOW) were given for reaction {}', reaction) + 'LOW) were given for reaction {}.', reaction) elif surface: reaction.kinetics = SurfaceRate(rate=arrhenius, coverages=coverages, diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index c25d4cc604..bd1d45767b 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -509,10 +509,9 @@ def test_duplicate_reactions(self): self.assertIn(token, message) def test_error_for_big_element_number(self): - with self.assertRaisesRegex(self.InputError, 'Element amounts'): + with self.assertRaisesRegex(self.InputError, 'Element amounts can have no more than 3 digits.'): self.convert('big_element_num_err.inp') - class CtmlConverterTest(utilities.CanteraTest): def test_sofc(self): gas_a, anode_bulk, oxide_a = ct.import_phases(