Clan-app/api: improve error message for mismatching types

This commit is contained in:
Johannes Kirschbauer
2024-11-28 16:30:29 +01:00
parent d3be596c77
commit ee9fdb7ac7

View File

@@ -160,7 +160,7 @@ def construct_value(
if loc is None:
loc = []
if t is None and field_value:
msg = f"Expected None but got: {field_value}"
msg = f"Trying to construct field of type None. But got: {field_value}. loc: {loc}"
raise ClanError(msg, location=f"{loc}")
if is_type_in_union(t, type(None)) and field_value is None:
@@ -319,4 +319,5 @@ def from_dict(
msg = f"{data} is not a dict. Expected {t}"
raise ClanError(msg)
return construct_dataclass(t, data, path) # type: ignore
# breakpoint()
return construct_value(t, data, path)