Coverage for health / utils / exceptions.py: 82%
17 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-02 17:44 +0800
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-02 17:44 +0800
1"""
2Custom exceptions for Garmin Health Sync system.
3"""
6class HealthSyncError(Exception):
7 """Base exception for all health sync errors."""
9 pass
12class GarminAuthError(HealthSyncError):
13 """Raised when Garmin authentication fails."""
15 pass
18class GarminAPIError(HealthSyncError):
19 """Raised when Garmin API returns an error."""
21 def __init__(self, message: str, status_code: int | None = None) -> None:
22 """Initialize GarminAPIError.
24 Args:
25 message: Error message
26 status_code: HTTP status code if available
27 """
28 super().__init__(message)
29 self.status_code = status_code
32class DataValidationError(HealthSyncError):
33 """Raised when data validation fails."""
35 pass
38class StorageError(HealthSyncError):
39 """Raised when file or database storage operations fail."""
41 pass
44class SyncError(HealthSyncError):
45 """Raised when data synchronization fails."""
47 pass
50class RateLimitError(GarminAPIError):
51 """Raised when API rate limit is exceeded."""
53 def __init__(self, message: str = "API rate limit exceeded") -> None:
54 """Initialize RateLimitError.
56 Args:
57 message: Error message
58 """
59 super().__init__(message, status_code=429)