Improve error messages

This commit is contained in:
LilyRose2798 2024-04-28 19:22:33 +10:00
parent 88d3a13dc6
commit 30cfa3dd03
1 changed files with 1 additions and 5 deletions

View File

@ -249,11 +249,7 @@ def format_exception(exc: BaseException, type: type | None) -> str:
if isinstance(exc, KeyError):
res = "required field missing"
elif isinstance(exc, ValueError):
if type is not None:
tn = type.__name__ if hasattr(type, "__name__") else repr(type)
res = f"invalid value for type, expected {tn}"
else:
res = f"invalid value ({exc})"
res = f"invalid value ({exc})"
elif isinstance(exc, TypeError):
if type is None:
if exc.args[0].endswith("object is not iterable"):