Skip to content
Snippets Groups Projects
Commit 46d476af authored by florian's avatar florian
Browse files

ENH: add get_code function for TransactionErrors caused by container

parent 32bfd737
Branches
No related tags found
No related merge requests found
......@@ -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 |--"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment