diff --git a/src/pybamm/util.py b/src/pybamm/util.py index 5b10b23fcb..39fcdde6f1 100644 --- a/src/pybamm/util.py +++ b/src/pybamm/util.py @@ -94,10 +94,16 @@ def __getitem__(self, key): ) from error best_matches = self.get_best_matches(key) for k in best_matches: - if key in k and k.endswith("]"): + if key in k and k.endswith("]") and not key.endswith("]"): raise KeyError( f"'{key}' not found. Use the dimensional version '{k}' instead." ) from error + elif key in k and ( + k.startswith("Primary") or k.startswith("Secondary") + ): + raise KeyError( + f"'{key}' not found. If you are using a composite model, you may need to use {k} instead. Otherwise, best matches are {best_matches}" + ) from error raise KeyError( f"'{key}' not found. Best matches are {best_matches}" ) from error