Coverage for src/lexigram/admin/contributors/exceptions.py: 100%
15 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-21 14:56 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-21 14:56 +0800
1"""Admin contributor exceptions — raised during contributor action dispatch."""
3from __future__ import annotations
5from lexigram.contracts.admin.errors import AdminError
8class ContributorPermissionError(AdminError):
9 """Raised when a user lacks required permissions to execute a contributor action.
11 Contains the contributor ID, action name, and the missing permissions.
13 Args:
14 contributor_id: Identifier of the contributor that owns the action.
15 action_name: Name of the action that was attempted.
16 missing_permissions: Permissions the user lacks.
17 """
19 _code: str = "LEX_ERR_ADMIN_020"
21 def __init__(
22 self,
23 contributor_id: str,
24 action_name: str,
25 missing_permissions: frozenset[str],
26 ) -> None:
27 self.contributor_id = contributor_id
28 self.action_name = action_name
29 self.missing_permissions = missing_permissions
30 super().__init__(
31 f"Permission denied for action '{action_name}' on contributor "
32 f"'{contributor_id}'. Missing: {missing_permissions}"
33 )
36class ContributorNotFoundError(AdminError):
37 """Raised when a contributor ID cannot be found in the assembled dashboard.
39 Args:
40 contributor_id: The requested contributor ID that was not found.
41 """
43 _code: str = "LEX_ERR_ADMIN_021"
45 def __init__(self, contributor_id: str) -> None:
46 self.contributor_id = contributor_id
47 super().__init__(f"Contributor '{contributor_id}' not found in dashboard.")
50__all__ = [
51 "ContributorNotFoundError",
52 "ContributorPermissionError",
53]