From f43ddf2cd56e480f1096859520694c517acf9276 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 31 Aug 2025 15:51:34 +0200 Subject: [PATCH] Defer execution of error details --- src/ifcopenshell-python/ifcopenshell/file.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index 16444e3702..91d4c67372 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -338,14 +338,14 @@ class file: from . import Error, SchemaError exc, msg = { - READ_ERROR: (IOError, "Unable to open file for reading"), - NO_HEADER: (Error, "Unable to parse IFC SPF header"), - UNSUPPORTED_SCHEMA: ( + READ_ERROR: lambda: (IOError, "Unable to open file for reading"), + NO_HEADER: lambda: (Error, "Unable to parse IFC SPF header"), + UNSUPPORTED_SCHEMA: lambda: ( SchemaError, "Unsupported schema: %s" % ",".join(f.header.file_schema.schema_identifiers), ), - INVALID_SYNTAX: (Error, "Syntax error during parse, check logs"), - }[f.good().value()] + INVALID_SYNTAX: lambda: (Error, "Syntax error during parse, check logs"), + }[f.good().value()]() raise exc(msg) self.wrapped_data = f else: