Skip to content

exceptions

AIHordeRequestError

Bases: HordeException

Exception for when the AI Horde API returns an error response.

Source code in horde_sdk/ai_horde_api/exceptions.py
class AIHordeRequestError(HordeException):
    """Exception for when the AI Horde API returns an error response."""

    def __init__(self, error_response: RequestErrorResponse) -> None:
        """Initialize an AI Horde request error.

        Args:
            error_response (RequestErrorResponse): The error response returned by the AI Horde API.
        """
        logger.error(f"The AI Horde API returned an error response. Response: {error_response.message}")
        super().__init__(error_response.message)
        try:
            RC(error_response.rc)
        except ValueError:
            logger.error(
                f"Failed to parse the RC from the error response. RC: {error_response.rc}. Is the SDK out of date?",
            )

__init__

__init__(error_response: RequestErrorResponse) -> None

Initialize an AI Horde request error.

Parameters:

Source code in horde_sdk/ai_horde_api/exceptions.py
def __init__(self, error_response: RequestErrorResponse) -> None:
    """Initialize an AI Horde request error.

    Args:
        error_response (RequestErrorResponse): The error response returned by the AI Horde API.
    """
    logger.error(f"The AI Horde API returned an error response. Response: {error_response.message}")
    super().__init__(error_response.message)
    try:
        RC(error_response.rc)
    except ValueError:
        logger.error(
            f"Failed to parse the RC from the error response. RC: {error_response.rc}. Is the SDK out of date?",
        )

AIHordeImageValidationError

Bases: AIHordeRequestError

Exception for when the AI Horde API cannot parse a source image for img2img.

Source code in horde_sdk/ai_horde_api/exceptions.py
class AIHordeImageValidationError(AIHordeRequestError):
    """Exception for when the AI Horde API cannot parse a source image for img2img."""

__init__

__init__(error_response: RequestErrorResponse) -> None

Initialize an AI Horde request error.

Parameters:

Source code in horde_sdk/ai_horde_api/exceptions.py
def __init__(self, error_response: RequestErrorResponse) -> None:
    """Initialize an AI Horde request error.

    Args:
        error_response (RequestErrorResponse): The error response returned by the AI Horde API.
    """
    logger.error(f"The AI Horde API returned an error response. Response: {error_response.message}")
    super().__init__(error_response.message)
    try:
        RC(error_response.rc)
    except ValueError:
        logger.error(
            f"Failed to parse the RC from the error response. RC: {error_response.rc}. Is the SDK out of date?",
        )

AIHordeGenerationTimedOutError

Bases: HordeException

Exception for when the time limit for a generation request is reached.

Source code in horde_sdk/ai_horde_api/exceptions.py
class AIHordeGenerationTimedOutError(HordeException):
    """Exception for when the time limit for a generation request is reached."""

    def __init__(self, error_response: RequestErrorResponse) -> None:
        """Initialize an AI Horde generation timed out error.

        Args:
            error_response (RequestErrorResponse): The error response returned by the AI Horde API.
        """
        logger.error(
            f"The AI Horde API returned an error response. Response: {error_response.message}. "
            "This is likely because the generation timed out. "
            f"The default timeout is {GENERATION_MAX_LIFE} seconds.",
        )
        super().__init__(error_response)

__init__

__init__(error_response: RequestErrorResponse) -> None

Initialize an AI Horde generation timed out error.

Parameters:

Source code in horde_sdk/ai_horde_api/exceptions.py
def __init__(self, error_response: RequestErrorResponse) -> None:
    """Initialize an AI Horde generation timed out error.

    Args:
        error_response (RequestErrorResponse): The error response returned by the AI Horde API.
    """
    logger.error(
        f"The AI Horde API returned an error response. Response: {error_response.message}. "
        "This is likely because the generation timed out. "
        f"The default timeout is {GENERATION_MAX_LIFE} seconds.",
    )
    super().__init__(error_response)

AIHordeServerException

Bases: HordeException

Base exception for any case where the AI Horde API returns a RequestErrorResponse and it was not handled.

Source code in horde_sdk/ai_horde_api/exceptions.py
class AIHordeServerException(HordeException):
    """Base exception for any case where the AI Horde API returns a `RequestErrorResponse` and it was not handled."""

    def __init__(
        self,
        *,
        message: str = "The AI Horde API returned an error response and it wasn't handled.",
        error_response: RequestErrorResponse,
    ) -> None:
        """Initialize the exception.

        Args:
            message: The message to display to the user.
            error_response: The error response returned by the AI Horde API.
        """
        logger.error(f"The AI Horde API returned an error response and it wasn't handled. Response: {error_response}")
        if error_response.object_data is not None:
            logger.error(f"Response object data: {error_response.object_data}")
        super().__init__(message)

__init__

__init__(
    *,
    message: str = "The AI Horde API returned an error response and it wasn't handled.",
    error_response: RequestErrorResponse
) -> None

Initialize the exception.

Parameters:

  • message (str, default: "The AI Horde API returned an error response and it wasn't handled." ) –

    The message to display to the user.

  • error_response (RequestErrorResponse) –

    The error response returned by the AI Horde API.

Source code in horde_sdk/ai_horde_api/exceptions.py
def __init__(
    self,
    *,
    message: str = "The AI Horde API returned an error response and it wasn't handled.",
    error_response: RequestErrorResponse,
) -> None:
    """Initialize the exception.

    Args:
        message: The message to display to the user.
        error_response: The error response returned by the AI Horde API.
    """
    logger.error(f"The AI Horde API returned an error response and it wasn't handled. Response: {error_response}")
    if error_response.object_data is not None:
        logger.error(f"Response object data: {error_response.object_data}")
    super().__init__(message)