"""
Domain Exceptions for {{ TableNamePascal }}

This module defines domain-specific exceptions.
"""
from typing import Optional


class DomainException(Exception):
    """Base domain exception."""
    
    def __init__(self, message: str, code: Optional[str] = None):
        self.message = message
        self.code = code or self.__class__.__name__
        super().__init__(self.message)


class {{ TableNamePascal }}NotFoundException(DomainException):
    """Exception raised when {{ TableNamePascal }} is not found."""
    
    def __init__(self, id: str):
        super().__init__(
            message=f"{{ TableNamePascal }} with id {id} not found",
            code="ENTITY_NOT_FOUND"
        )


class {{ TableNamePascal }}AlreadyExistsException(DomainException):
    """Exception raised when {{ TableNamePascal }} already exists."""
    
    def __init__(self, field: str, value: str):
        super().__init__(
            message=f"{{ TableNamePascal }} with {field}={value} already exists",
            code="ENTITY_ALREADY_EXISTS"
        )


class {{ TableNamePascal }}ValidationException(DomainException):
    """Exception raised when {{ TableNamePascal }} validation fails."""
    
    def __init__(self, message: str):
        super().__init__(
            message=message,
            code="VALIDATION_ERROR"
        )