mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
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:
@@ -338,7 +338,18 @@ class entity_instance:
|
|||||||
)
|
)
|
||||||
raise e
|
raise e
|
||||||
else:
|
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
|
return value
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user