"""
Custom Database Exceptions
Provides consistent error handling across all microservices
"""

class DatabaseError(Exception):
    """Base exception for database-related errors"""
    
    def __init__(self, message: str, details: dict = None):
        self.message = message
        self.details = details or {}
        super().__init__(self.message)


class ConnectionError(DatabaseError):
    """Raised when database connection fails"""
    pass


class RecordNotFoundError(DatabaseError):
    """Raised when a requested record is not found"""
    pass


class DuplicateRecordError(DatabaseError):
    """Raised when trying to create a duplicate record"""
    pass


class ConstraintViolationError(DatabaseError):
    """Raised when database constraints are violated"""
    pass


class TransactionError(DatabaseError):
    """Raised when transaction operations fail"""
    pass


class ValidationError(DatabaseError):
    """Raised when data validation fails before database operations"""
    pass


class MigrationError(DatabaseError):
    """Raised when database migration operations fail"""
    pass


class HealthCheckError(DatabaseError):
    """Raised when database health checks fail"""
    pass