"""Domain exception hiyerarşisi. Ham hata client'a verilmez — hep sarmalanır."""


class FlovyException(Exception):
    def __init__(self, code: str, message: str, status_code: int = 400):
        self.code = code
        self.message = message
        self.status_code = status_code
        super().__init__(message)


class NotFoundError(FlovyException):
    def __init__(self, resource: str = "Kayıt"):
        super().__init__("NOT_FOUND", f"{resource} bulunamadı.", 404)


class PermissionDeniedError(FlovyException):
    def __init__(self, message: str = "Bu işlem için yetkiniz yok."):
        super().__init__("FORBIDDEN", message, 403)


class UnauthorizedError(FlovyException):
    def __init__(self, message: str = "Kimlik doğrulaması gerekli."):
        super().__init__("UNAUTHORIZED", message, 401)


class ValidationError(FlovyException):
    def __init__(self, message: str):
        super().__init__("VALIDATION_FAILED", message, 422)


class ConflictError(FlovyException):
    def __init__(self, message: str):
        super().__init__("CONFLICT", message, 409)


class QuotaExceededError(FlovyException):
    def __init__(self, quota_type: str = "Mesaj"):
        super().__init__("QUOTA_EXCEEDED", f"{quota_type} kotanız dolmuş.", 429)


class ExternalServiceError(FlovyException):
    def __init__(self, code: str, message: str, status_code: int = 503):
        super().__init__(code, message, status_code)
