diff --git a/capellambse_context_diagrams/collectors/exchanges.py b/capellambse_context_diagrams/collectors/exchanges.py index 8f7ff12..0d425d7 100644 --- a/capellambse_context_diagrams/collectors/exchanges.py +++ b/capellambse_context_diagrams/collectors/exchanges.py @@ -163,6 +163,12 @@ def get_left_and_right(self) -> None: self.data.children.append(self.left) assert self.right is not None self.data.children.append(self.right) + if self.left == self.right: + raise errors.CycleError( + "The interface is a cycle, connecting the same " + "source and target." + ) + except AttributeError as error: logger.exception("Interface collection failed: \n%r", str(error)) diff --git a/capellambse_context_diagrams/errors.py b/capellambse_context_diagrams/errors.py index c557c5b..c164546 100644 --- a/capellambse_context_diagrams/errors.py +++ b/capellambse_context_diagrams/errors.py @@ -6,3 +6,7 @@ class CapellambseError(Exception): """Error raised by capellambse.""" + + +class CycleError(CapellambseError): + """Error raised when a cycle is detected."""