cloud-api/src/organisation/exceptions.py

28 lines
873 B
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
2026-05-28 14:23:36 +01:00
Exceptions related to the organisation module
2026-04-06 12:41:49 +01:00
Exceptions:
2026-05-28 14:23:36 +01:00
- OrgNotFoundException: Takes an optional org_id int
- AwaitingApprovalException: Takes an optional org_id int
"""
from typing import Optional
from fastapi import HTTPException, status
class OrgNotFoundException(HTTPException):
def __init__(self, org_id: Optional[int] = None) -> None:
2026-05-27 13:33:30 +01:00
detail = "Organisation not found" if org_id is None else f"Organisation with ID '{org_id}' was not found."
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=detail,
2026-05-27 13:33:30 +01:00
)
class AwaitingApprovalException(HTTPException):
def __init__(self, org_id: Optional[int] = None) -> None:
detail = "Organisation has not been approved." if org_id is None else f"Organisation with ID '{org_id}' has not been approved."
super().__init__(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=detail,
)