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
|
||||
if validate:
|
||||
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:
|
||||
raise Exception(f'Unknown key "{key}"')
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue