"""
==================================================
Smart Attendance AI
Custom Exceptions
==================================================
"""


class AIException(Exception):
    """
    Base Exception for all AI errors.
    """

    def __init__(self, message="AI Service Error"):

        self.message = message

        super().__init__(self.message)


# ==========================================
# Image Exceptions
# ==========================================

class InvalidImageException(AIException):

    def __init__(self):

        super().__init__(
            "Invalid image file."
        )


class UnsupportedImageFormatException(AIException):

    def __init__(self):

        super().__init__(
            "Unsupported image format."
        )


class ImageTooLargeException(AIException):

    def __init__(self):

        super().__init__(
            "Image size exceeds allowed limit."
        )


# ==========================================
# Face Detection Exceptions
# ==========================================

class NoFaceDetectedException(AIException):

    def __init__(self):

        super().__init__(
            "No face detected."
        )


class MultipleFacesDetectedException(AIException):

    def __init__(self):

        super().__init__(
            "Multiple faces detected."
        )


class FaceTooSmallException(AIException):

    def __init__(self):

        super().__init__(
            "Detected face is too small."
        )


class LowQualityFaceException(AIException):

    def __init__(self):

        super().__init__(
            "Face quality is too low."
        )


# ==========================================
# Recognition Exceptions
# ==========================================

class UnknownFaceException(AIException):

    def __init__(self):

        super().__init__(
            "Unknown face."
        )


class EmbeddingNotFoundException(AIException):

    def __init__(self):

        super().__init__(
            "Embedding not found."
        )


class NoStudentEmbeddingsException(AIException):

    def __init__(self):

        super().__init__(
            "No student embeddings provided."
        )


# ==========================================
# Training Exceptions
# ==========================================

class TrainingFailedException(AIException):

    def __init__(self):

        super().__init__(
            "Face training failed."
        )


class TooFewTrainingImagesException(AIException):

    def __init__(self):

        super().__init__(
            "Minimum training images not provided."
        )


class TooManyTrainingImagesException(AIException):

    def __init__(self):

        super().__init__(
            "Too many training images."
        )


class MultipleTrainingFacesException(AIException):

    def __init__(self):

        super().__init__(
            "Exactly one face is required in each training image."
        )


class NoEmbeddingGeneratedException(AIException):

    def __init__(self):

        super().__init__(
            "No embeddings could be generated."
        )


# ==========================================
# AI Model Exceptions
# ==========================================

class ModelNotLoadedException(AIException):

    def __init__(self):

        super().__init__(
            "AI model is not loaded."
        )


class ModelLoadException(AIException):

    def __init__(self):

        super().__init__(
            "Unable to load AI model."
        )