From b3903cba5d3cdae1652b62b6bb3e5a67dd1bbce4 Mon Sep 17 00:00:00 2001 From: Gavin Macaulay Date: Sat, 24 Aug 2024 11:00:35 +1200 Subject: [PATCH] Catch toml parsing errors and report filename that was being read --- src/echosms/referencemodels.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/echosms/referencemodels.py b/src/echosms/referencemodels.py index 82d478d..9bd5b40 100644 --- a/src/echosms/referencemodels.py +++ b/src/echosms/referencemodels.py @@ -30,7 +30,10 @@ def __init__(self): self.definitions = [] with open(self.defs_filename, 'rb') as f: - self.definitions = tomllib.load(f) + try: + self.definitions = tomllib.load(f) + except tomllib.TOMLDecodeError as e: + raise Exception(f'Error while parsing file "{self.defs_filename.name}"') from e # Flag duplicate target names pda = pd.Series(self.names())