mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-26 10:23:10 -04:00
dataclass: transform(): format types in error for wrong value type better
This commit is contained in:
parent
82a87e7ea9
commit
7d96d05165
1 changed files with 3 additions and 1 deletions
|
@ -70,7 +70,9 @@ class DataClass(Munch):
|
||||||
value = parsed_number
|
value = parsed_number
|
||||||
if validate:
|
if validate:
|
||||||
if not isinstance(value, _classes):
|
if not isinstance(value, _classes):
|
||||||
raise Exception(f'key "{key}" has value of wrong type {_classes}: {value}')
|
raise Exception(f'key "{key}" has value of wrong type! expected: '
|
||||||
|
f'{" ,".join([ c.__name__ for c in _classes])}; '
|
||||||
|
f'got: {type(value).__name__}; value: {value}')
|
||||||
elif validate and not allow_extra:
|
elif validate and not allow_extra:
|
||||||
raise Exception(f'Unknown key "{key}"')
|
raise Exception(f'Unknown key "{key}"')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue