Skip to content

Commit

Permalink
Raise from exception + improve wording
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasG0 committed Sep 11, 2024
1 parent aa3e390 commit d4a3095
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions backend/infrahub/core/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,12 +903,12 @@ def validate_menu_placements(self) -> None:
if node.menu_placement:
try:
placement_node = self.get(name=node.menu_placement, duplicate=False)
except SchemaNotFoundError:
except SchemaNotFoundError as exc:
raise SchemaNotFoundError(
branch_name=self.name,
identifier=node.menu_placement,
message=f"{node.kind} refers an unexisting menu placement node: {node.menu_placement}.",
)
message=f"{node.kind} refers to an invalid menu placement node: {node.menu_placement}.",
) from exc
if node == placement_node:
raise ValueError(f"{node.kind}: cannot be placed under itself in the menu") from None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ async def test_schema_missing_menu_placement(self, client: InfrahubClient):
assert response.errors["errors"][0]["extensions"]["code"] == 422
assert (
response.errors["errors"][0]["message"]
== "InfraBNode refers an unexisting menu placement node: UnexistingNode."
== "InfraBNode refers to an invalid menu placement node: UnexistingNode."
)
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ async def test_schema_branch_validate_menu_placement():
with pytest.raises(SchemaNotFoundError) as exc:
schema.validate_menu_placements()

assert exc.value.message == "TestSubObject refers an unexisting menu placement node: NoSuchObject."
assert exc.value.message == "TestSubObject refers to an invalid menu placement node: NoSuchObject."


async def test_schema_branch_validate_same_node_menu_placement():
Expand Down

0 comments on commit d4a3095

Please sign in to comment.