Coverage for api_client/exceptions.py: 66.67%
12 statements
« prev ^ index » next coverage.py v7.10.6, created at 2026-04-15 13:38 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2026-04-15 13:38 +0000
1"""Custom exceptions for API client."""
4class APIError(Exception):
5 """Base exception for API errors."""
7 def __init__(self, message: str, status_code: int | None = None, response_data: dict | None = None):
8 self.message = message
9 self.status_code = status_code
10 self.response_data = response_data
11 super().__init__(self.message)
14class AuthenticationError(APIError):
15 """Raised when authentication fails (401)."""
17 pass
20class AuthorizationError(APIError):
21 """Raised when authorization fails (403)."""
23 pass
26class NotFoundError(APIError):
27 """Raised when resource is not found (404)."""
29 pass
32class ValidationError(APIError):
33 """Raised when validation fails (422)."""
35 pass
38class RateLimitError(APIError):
39 """Raised when rate limit is exceeded (429)."""
41 pass
44class ServerError(APIError):
45 """Raised when server returns 5xx error."""
47 pass