From 866636b3c41ac957a0a71d63f292e167031cf957 Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Wed, 8 Jul 2020 17:21:19 +0200
Subject: [PATCH] ENH: Attach containers to TransactionError; remove
 ContainerError

---
 src/caosdb/common/models.py | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 4792f46c..17822a2f 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -49,7 +49,7 @@ from caosdb.connection.encode import MultipartParam, multipart_encode
 from caosdb.exceptions import (AmbiguityException,
                                AuthorizationException,
                                CaosDBException, ConnectionException,
-                               ConsistencyError, ContainerError,
+                               ConsistencyError,
                                EntityDoesNotExistError, EntityError,
                                EntityHasNoDatatypeError,
                                TransactionError, UniqueNamesError,
@@ -3759,20 +3759,14 @@ def _evaluate_and_add_error(parent_error, ent):
                 parent_error.add_error(dummy_err)
 
     elif isinstance(ent, Container):
+        parent_error.container = ent
         if ent.get_errors() is not None:
-            for err in ent.get_errors():
-                cont_err = ContainerError(entity=ent, error=err)
-                for elt in ent:
-                    cont_err = _evaluate_and_add_error(cont_err, elt)
-                parent_error.add_error(cont_err)
-        # Cover possibility that the container doesn't have an error
-        # but still contains entities that do
-        else:
-            dummy_err = ContainerError(entity=ent)
-            for elt in ent:
-                dummy_err = _evaluate_and_add_error(dummy_err, elt)
-            if dummy_err.get_errors():
-                parent_error.add_error(dummy_err)
+            # In the highly unusual case of more than one error
+            # message, attach all of them.
+            parent_error.msg = '\n'.join(ent.get_errors())
+        # Go through all container elements and add them:
+        for elt in ent:
+            parent_error = _evaluate_and_add_error(parent_error, elt)
 
     else:
         raise TypeError("Parameter ent is to be an Entity or a Container")
-- 
GitLab