diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 3beec3cc14779e8ffa35d28f3fa91260b52b6645..4ff840a64a11681ea2f9c360cd0f8b48a41a7b82 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -257,6 +257,7 @@ class TransactionError(CaosDBException): self.entities instead. """ + if self.container is not None: return self.container from caosdb import Container @@ -289,6 +290,18 @@ class TransactionError(CaosDBException): "This TransActionError was caused by more than one EntityError." ) + def get_code(self): + """In the special case of a container with at least one error message + with an integer code, return that code. Return None + otherwise. + + """ + + if self.container is not None and self.container.get_errors() is not None: + for err in self.container.get_errors(): + if err.code is not None: + return err.code + def _repr_reasons(self, indent): if self.get_errors() is not None and len(self.get_errors()) > 0: ret = "\n" + indent + " +--| REASONS |--"