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):
|
if isinstance(exc, KeyError):
|
||||||
res = "required field missing"
|
res = "required field missing"
|
||||||
elif isinstance(exc, ValueError):
|
elif isinstance(exc, ValueError):
|
||||||
if type is not None:
|
res = f"invalid value ({exc})"
|
||||||
tn = type.__name__ if hasattr(type, "__name__") else repr(type)
|
|
||||||
res = f"invalid value for type, expected {tn}"
|
|
||||||
else:
|
|
||||||
res = f"invalid value ({exc})"
|
|
||||||
elif isinstance(exc, TypeError):
|
elif isinstance(exc, TypeError):
|
||||||
if type is None:
|
if type is None:
|
||||||
if exc.args[0].endswith("object is not iterable"):
|
if exc.args[0].endswith("object is not iterable"):
|
||||||
|
|
Loading…
Reference in New Issue