From d058cd50da7b08fd45af05d61207662cc714e2db Mon Sep 17 00:00:00 2001 From: juk0de <5322305+juk0de@users.noreply.github.com> Date: Sun, 21 Jul 2024 09:24:38 +0200 Subject: [PATCH] mtf2json: improved error messages for fluff section --- mtf2json/mtf2json.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mtf2json/mtf2json.py b/mtf2json/mtf2json.py index c16145e..9594440 100755 --- a/mtf2json/mtf2json.py +++ b/mtf2json/mtf2json.py @@ -679,11 +679,14 @@ def __add_fluff(key: str, value: str, fluff_section: Dict[str, Union[str, List[s # the key is already in the fluff section # -> it's a subsection if key in fluff_section: - subkey, subvalue = value.split(':', 1) + try: + subkey, subvalue = value.split(':', 1) + except Exception as e: + raise ConversionError(f"Key '{key}' already exists in the fluff section but value is missing the ':' delimiter: {e}") if isinstance(fluff_section[key], dict): cast(dict, fluff_section[key])[subkey.lower()] = subvalue.strip() else: - raise ConversionError(f"Fluff key entry '{key}' is not a dictionary!") + raise ConversionError(f"Tried to add '{subkey}:{subvalue}' to fluff section '{key}', but '{key}' is not a dictionary!") # the key is new else: # value contains a subkey