From: Joerg Behrmann Date: Wed, 27 Sep 2023 10:46:32 +0000 (+0200) Subject: json: produce a known error when parsing JSON X-Git-Tag: v18~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac6803cdea8111815291e055a0db6aa8896df10d;p=thirdparty%2Fmkosi.git json: produce a known error when parsing JSON --- diff --git a/mkosi/config.py b/mkosi/config.py index e1df2b153..1a4202dee 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -2802,7 +2802,10 @@ def json_type_transformer(refcls: Union[type[MkosiArgs], type[MkosiConfig]]) -> assert fieldtype is not None transformer = cast(Optional[Callable[[str, type], Any]], transformers.get(fieldtype.type)) if transformer is not None: - return transformer(val, fieldtype.type) + try: + return transformer(val, fieldtype.type) + except (ValueError, IndexError, AssertionError) as e: + raise ValueError(f"Unable to parse {val:r} for attribute {key:r} for {refcls.__name__}") from e return val