Improve error messages
This commit is contained in:
parent
88d3a13dc6
commit
30cfa3dd03
6
woven.py
6
woven.py
|
@ -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"):
|
||||
|
|
Loading…
Reference in New Issue