Skip to content

errors

OpenTriviaDB errors.

InvalidParameter

Bases: OpenTriviaError

An invalid parameter was passed to the API.

Source code in opentriviadb/errors.py
class InvalidParameter(OpenTriviaError):
    """An invalid parameter was passed to the API."""

    def __init__(self) -> None:
        super().__init__(
            "an invalid parameter has been passed -- refer to the docs to "
            "check valid values"
        )

NoResults

Bases: OpenTriviaError

Exception thrown when no results can be returned from the API.

Source code in opentriviadb/errors.py
class NoResults(OpenTriviaError):
    """Exception thrown when no results can be returned from the API."""

    def __init__(self) -> None:
        super().__init__("the API does not have enough questions for your query")

OpenTriviaError

Bases: Exception

The base error for OpenTriviaDB errors.

Source code in opentriviadb/errors.py
class OpenTriviaError(Exception):
    """The base error for OpenTriviaDB errors."""

TokenEmpty

Bases: OpenTriviaError

All possible questions have been returned while the active session token is in use, and the token should be reset.

Source code in opentriviadb/errors.py
class TokenEmpty(OpenTriviaError):
    """All possible questions have been returned while the active
    session token is in use, and the token should be reset."""

    def __init__(self) -> None:
        super().__init__(
            "all possible questions returned using current token -- use "
            "`client.reset_token` to reset it"
        )

TokenNotFound

Bases: OpenTriviaError

A session token is required for the request, but does not exist.

Source code in opentriviadb/errors.py
class TokenNotFound(OpenTriviaError):
    """A session token is required for the request, but does not
    exist."""

    def __init__(self) -> None:
        super().__init__(
            "session token does not exist -- use `client.retrieve_token` to "
            "create a new one"
        )