"""
Custom exceptions for Garmin Health Sync system.
"""


class HealthSyncError(Exception):
    """Base exception for all health sync errors."""

    pass


class GarminAuthError(HealthSyncError):
    """Raised when Garmin authentication fails."""

    pass


class GarminAPIError(HealthSyncError):
    """Raised when Garmin API returns an error."""

    def __init__(self, message: str, status_code: int | None = None) -> None:
        """Initialize GarminAPIError.

        Args:
            message: Error message
            status_code: HTTP status code if available
        """
        super().__init__(message)
        self.status_code = status_code


class DataValidationError(HealthSyncError):
    """Raised when data validation fails."""

    pass


class StorageError(HealthSyncError):
    """Raised when file or database storage operations fail."""

    pass


class SyncError(HealthSyncError):
    """Raised when data synchronization fails."""

    pass


class RateLimitError(GarminAPIError):
    """Raised when API rate limit is exceeded."""

    def __init__(self, message: str = "API rate limit exceeded") -> None:
        """Initialize RateLimitError.

        Args:
            message: Error message
        """
        super().__init__(message, status_code=429)
