Skip to content

API Documentation - Exceptions

Custom exceptions for the MeteoLux API client.

HTTPError

Bases: MeteoLuxError

A generic HTTP error.

Source code in meteolux/exceptions.py
class HTTPError(MeteoLuxError):
  """A generic HTTP error."""

  def __init__(self, status_code: int, detail: str) -> None:
    """Initializes the HTTPError with a status code and detail message.

    Args:
        status_code (int): The HTTP status code.
        detail (str): The error message from the API.
    """
    self.status_code = status_code
    self.detail = detail
    super().__init__(f'HTTP Error {self.status_code}: {self.detail}')

__init__(status_code, detail)

Initializes the HTTPError with a status code and detail message.

Parameters:

Name Type Description Default
status_code int

The HTTP status code.

required
detail str

The error message from the API.

required
Source code in meteolux/exceptions.py
def __init__(self, status_code: int, detail: str) -> None:
  """Initializes the HTTPError with a status code and detail message.

  Args:
      status_code (int): The HTTP status code.
      detail (str): The error message from the API.
  """
  self.status_code = status_code
  self.detail = detail
  super().__init__(f'HTTP Error {self.status_code}: {self.detail}')

HTTPValidationError

Bases: MeteoLuxError

Raised when the API returns a 422 Unprocessable Entity status.

Source code in meteolux/exceptions.py
class HTTPValidationError(MeteoLuxError):
  """Raised when the API returns a 422 Unprocessable Entity status."""

  def __init__(self, detail: str) -> None:
    """Initializes the HTTPValidationError with a detail message.

    Args:
        detail (str): The error message from the API.
    """
    self.detail = detail
    super().__init__(self.detail)

__init__(detail)

Initializes the HTTPValidationError with a detail message.

Parameters:

Name Type Description Default
detail str

The error message from the API.

required
Source code in meteolux/exceptions.py
def __init__(self, detail: str) -> None:
  """Initializes the HTTPValidationError with a detail message.

  Args:
      detail (str): The error message from the API.
  """
  self.detail = detail
  super().__init__(self.detail)

MeteoLuxError

Bases: Exception

Base exception for the MeteoLux API client.

Source code in meteolux/exceptions.py
class MeteoLuxError(Exception):
  """Base exception for the MeteoLux API client."""

NotFoundError

Bases: MeteoLuxError

Raised when the API returns a 404 Not Found status.

Source code in meteolux/exceptions.py
class NotFoundError(MeteoLuxError):
  """Raised when the API returns a 404 Not Found status."""

  def __init__(self, detail: str) -> None:
    """Initializes the NotFoundError with a detail message.

    Args:
        detail (str): The error message from the API.
    """
    self.detail = detail
    super().__init__(self.detail)

__init__(detail)

Initializes the NotFoundError with a detail message.

Parameters:

Name Type Description Default
detail str

The error message from the API.

required
Source code in meteolux/exceptions.py
def __init__(self, detail: str) -> None:
  """Initializes the NotFoundError with a detail message.

  Args:
      detail (str): The error message from the API.
  """
  self.detail = detail
  super().__init__(self.detail)

ValidationError

Bases: MeteoLuxError

Raised when there is a validation error in the Pydantic models.

Source code in meteolux/exceptions.py
class ValidationError(MeteoLuxError):
  """Raised when there is a validation error in the Pydantic models."""

  def __init__(self, detail: str) -> None:
    """Initializes the ValidationError with a detail message.

    Args:
        detail (str): The error message from the API.
    """
    self.detail = detail
    super().__init__(self.detail)

__init__(detail)

Initializes the ValidationError with a detail message.

Parameters:

Name Type Description Default
detail str

The error message from the API.

required
Source code in meteolux/exceptions.py
def __init__(self, detail: str) -> None:
  """Initializes the ValidationError with a detail message.

  Args:
      detail (str): The error message from the API.
  """
  self.detail = detail
  super().__init__(self.detail)