Skip to content

Exceptions API Reference

healthsites.exceptions

Custom exceptions for the Healthsites API client.

Classes

AuthenticationError

Bases: HealthsitesError

Raised when API authentication fails.

Source code in healthsites/exceptions.py
15
16
17
18
19
class AuthenticationError(HealthsitesError):
    """Raised when API authentication fails."""

    def __init__(self, message: str = "Invalid or missing API key"):
        super().__init__(message, status_code=401)

HealthsitesError

Bases: Exception

Base exception for all Healthsites API errors.

Source code in healthsites/exceptions.py
 6
 7
 8
 9
10
11
12
class HealthsitesError(Exception):
    """Base exception for all Healthsites API errors."""

    def __init__(self, message: str, status_code: int | None = None):
        self.message = message
        self.status_code = status_code
        super().__init__(self.message)

NotFoundError

Bases: HealthsitesError

Raised when a requested resource is not found.

Source code in healthsites/exceptions.py
22
23
24
25
26
class NotFoundError(HealthsitesError):
    """Raised when a requested resource is not found."""

    def __init__(self, message: str = "Resource not found"):
        super().__init__(message, status_code=404)

RateLimitError

Bases: HealthsitesError

Raised when API rate limit is exceeded.

Source code in healthsites/exceptions.py
29
30
31
32
33
class RateLimitError(HealthsitesError):
    """Raised when API rate limit is exceeded."""

    def __init__(self, message: str = "Rate limit exceeded"):
        super().__init__(message, status_code=429)

ValidationError

Bases: HealthsitesError

Raised when request validation fails.

Source code in healthsites/exceptions.py
36
37
38
39
40
class ValidationError(HealthsitesError):
    """Raised when request validation fails."""

    def __init__(self, message: str = "Validation error"):
        super().__init__(message, status_code=400)

Made with love by Kartoza | Donate! | GitHub