Skip to content

Commit

Permalink
fix: Raise an exception when left and right are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Oct 22, 2024
1 parent 299e483 commit b24dca6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions capellambse_context_diagrams/collectors/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 4 additions & 0 deletions capellambse_context_diagrams/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@

class CapellambseError(Exception):
"""Error raised by capellambse."""


class CycleError(CapellambseError):
"""Error raised when a cycle is detected."""

0 comments on commit b24dca6

Please sign in to comment.