From 68a602573b8bffdc826e1bd1f9e9e3f10ac88912 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 2 Jul 2025 16:55:42 +0500 Subject: [PATCH] ifcopenshell.geom.iterator - more descriptive error in `__init__` #6865 --- src/ifcopenshell-python/ifcopenshell/geom/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index 620cc026e9..4e105b3e0a 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -322,8 +322,10 @@ class iterator(ifcopenshell_wrapper.Iterator): if include_or_exclude_type == {"entity_instance"}: include_or_exclude = cast(set[entity_instance], include_or_exclude) - if not all(inst.is_a("IfcProduct") for inst in include_or_exclude): - raise ValueError("include and exclude need to be an aggregate of IfcProduct") + if not all((last_inst := inst).is_a("IfcProduct") for inst in include_or_exclude): + raise ValueError( + f"include and exclude need to be an aggregate of IfcProduct. Violating element: '{last_inst}'." + ) initializer = ifcopenshell_wrapper.construct_iterator_with_include_exclude_id