"""Domain-specific HTTP exceptions for the DAK Zweitmeinungs-Portal.""" from fastapi import HTTPException, status class CaseNotFoundError(HTTPException): """Raised when a requested case does not exist (404).""" def __init__(self, detail: str = "Case not found") -> None: super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail) class DuplicateCaseError(HTTPException): """Raised when a case with the same identifier already exists (409).""" def __init__(self, detail: str = "Case already exists") -> None: super().__init__(status_code=status.HTTP_409_CONFLICT, detail=detail) class InvalidImportFileError(HTTPException): """Raised when an uploaded import file is malformed or invalid (400).""" def __init__(self, detail: str = "Invalid import file") -> None: super().__init__(status_code=status.HTTP_400_BAD_REQUEST, detail=detail) class ICDValidationError(HTTPException): """Raised when ICD code validation fails (422).""" def __init__(self, detail: str = "ICD code validation failed") -> None: super().__init__( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=detail ) class AccountLockedError(HTTPException): """Raised when a user account is temporarily locked (423).""" def __init__(self, detail: str = "Account is locked") -> None: super().__init__(status_code=status.HTTP_423_LOCKED, detail=detail) class InvalidCredentialsError(HTTPException): """Raised when login credentials are incorrect (401).""" def __init__(self, detail: str = "Invalid credentials") -> None: super().__init__( status_code=status.HTTP_401_UNAUTHORIZED, detail=detail )