2026-05-25 09:05:17 +01:00
|
|
|
"""
|
2026-05-28 13:22:24 +01:00
|
|
|
Exceptions related to the IAM module
|
2026-05-25 09:05:17 +01:00
|
|
|
|
|
|
|
|
Exceptions:
|
2026-05-28 13:22:24 +01:00
|
|
|
- GroupNotFoundException: Takes an optional group_id int
|
|
|
|
|
- PermNotFoundException: Takes an optional perm_id int
|
2026-05-27 11:11:19 +01:00
|
|
|
"""
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-27 11:11:19 +01:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GroupNotFoundException(HTTPException):
|
|
|
|
|
def __init__(self, group_id: Optional[int] = None) -> None:
|
2026-06-08 15:31:37 +01:00
|
|
|
detail = (
|
|
|
|
|
"Group not found"
|
|
|
|
|
if group_id is None
|
|
|
|
|
else f"User with ID '{group_id}' was not found."
|
|
|
|
|
)
|
2026-05-27 11:11:19 +01:00
|
|
|
super().__init__(
|
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
|
detail=detail,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PermNotFoundException(HTTPException):
|
|
|
|
|
def __init__(self, perm_id: Optional[int] = None) -> None:
|
2026-06-08 15:31:37 +01:00
|
|
|
detail = (
|
|
|
|
|
"Permission not found"
|
|
|
|
|
if perm_id is None
|
|
|
|
|
else f"User with ID '{perm_id}' was not found."
|
|
|
|
|
)
|
2026-05-27 11:11:19 +01:00
|
|
|
super().__init__(
|
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
|
detail=detail,
|
|
|
|
|
)
|