Skip to content

Commit

Permalink
mtf2json: improved error messages for fluff section
Browse files Browse the repository at this point in the history
  • Loading branch information
juk0de committed Jul 21, 2024
1 parent 2b77e33 commit d058cd5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mtf2json/mtf2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d058cd5

Please sign in to comment.