ifcopenshell.file - save last failed transaction for introspection

This commit is contained in:
Andrej730
2025-05-07 17:47:06 +05:00
parent af4fbd6750
commit 64df82a76b
+14 -2
View File
@@ -59,6 +59,12 @@ HEADER_FIELDS = {
}
class UndoSystemError(Exception):
def __init__(self, message: str, transaction: Transaction):
super().__init__(message)
self.transaction = transaction
class Transaction:
def __init__(self, ifc_file: file):
self.file: file = ifc_file
@@ -342,14 +348,20 @@ class file:
if not self.history:
return
transaction = self.history.pop()
transaction.rollback()
try:
transaction.rollback()
except Exception as e:
raise UndoSystemError("Error during transaction undo.", transaction) from e
self.future.append(transaction)
def redo(self) -> None:
if not self.future:
return
transaction = self.future.pop()
transaction.commit()
try:
transaction.commit()
except Exception as e:
raise UndoSystemError("Error during transaction redo.", transaction) from e
self.history.append(transaction)
def create_entity(self, type: str, *args, **kwargs) -> ifcopenshell.entity_instance: