more descriptive errors settings incorrect data type to attributes

Example:
```
ifc_file = ifcopenshell.file(schema="IFC2X3")
entity = ifc_file.create_entity("IfcCostSchedule")

entity.UpdateDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime")
```
This commit is contained in:
Andrej730
2024-05-09 16:08:41 +05:00
parent 8ffb77551f
commit 1c6a9e2c49
@@ -338,7 +338,18 @@ class entity_instance:
)
raise e
else:
self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value))
try:
self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value))
except TypeError:
raise TypeError(
"attribute '%s' for entity '%s' is expecting value of type '%s', got '%s'."
% (
self.wrapped_data.get_argument_name(idx),
self.wrapped_data.is_a(True),
self.wrapped_data.get_argument_type(idx),
type(value).__name__,
)
)
return value