Improve error messages
This commit is contained in:
parent
88d3a13dc6
commit
30cfa3dd03
4
woven.py
4
woven.py
|
@ -249,10 +249,6 @@ 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:
|
|
||||||
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):
|
elif isinstance(exc, TypeError):
|
||||||
if type is None:
|
if type is None:
|
||||||
|
|
Loading…
Reference in New Issue