Exceptions and warnings that can be thrown by this library.

This module

Expand source code
Browse git
# -*- coding: utf-8 -*-
# cython: language_level=3
# Copyright (c) 2020 Nekokatt
# Copyright (c) 2021-present davfsa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Exceptions and warnings that can be thrown by this library."""

from __future__ import annotations

__all__: typing.Sequence[str] = (
    "HikariError",
    "HikariWarning",
    "HikariInterrupt",
    "ComponentStateConflictError",
    "UnrecognisedEntityError",
    "NotFoundError",
    "RateLimitedError",
    "RateLimitTooLongError",
    "UnauthorizedError",
    "ForbiddenError",
    "BadRequestError",
    "HTTPError",
    "HTTPResponseError",
    "ClientHTTPResponseError",
    "InternalServerError",
    "ShardCloseCode",
    "GatewayConnectionError",
    "GatewayServerClosedConnectionError",
    "GatewayError",
    "MissingIntentWarning",
    "MissingIntentError",
    "BulkDeleteError",
    "VoiceError",
)

import http
import typing

import attr

from hikari.internal import attr_extensions
from hikari.internal import data_binding
from hikari.internal import enums

if typing.TYPE_CHECKING:
    from hikari import intents as intents_
    from hikari import messages
    from hikari import snowflakes
    from hikari.internal import routes


# The standard exceptions are all unsloted so slotting here would be a waste of time.
@attr_extensions.with_copy
@attr.define(auto_exc=True, repr=False, init=False, slots=False)
class HikariError(RuntimeError):
    """Base for an error raised by this API.

    Any exceptions should derive from this.

    !!! note
        You should never initialize this exception directly.
    """


# The standard warnings are all unsloted so slotting here would be a waste of time.
@attr_extensions.with_copy
@attr.define(auto_exc=True, repr=False, init=False, slots=False)
class HikariWarning(RuntimeWarning):
    """Base for a warning raised by this API.

    Any warnings should derive from this.

    !!! note
        You should never initialize this warning directly.
    """


@attr.define(auto_exc=True, repr=False, slots=False)
class HikariInterrupt(KeyboardInterrupt, HikariError):
    """Exception raised when a kill signal is handled internally."""

    signum: int = attr.field()
    """The signal number that was raised."""

    signame: str = attr.field()
    """The signal name that was raised."""


@attr.define(auto_exc=True, repr=False, slots=False)
class ComponentStateConflictError(HikariError):
    """Exception thrown when an action cannot be executed in the component's current state.

    Dependent on context this will be thrown for components which are already
    running or haven't been started yet.
    """

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason


@attr.define(auto_exc=True, repr=False, slots=False)
class UnrecognisedEntityError(HikariError):
    """An exception thrown when an unrecognised entity is found."""

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason


@attr.define(auto_exc=True, repr=False, slots=False)
class GatewayError(HikariError):
    """A base exception type for anything that can be thrown by the Gateway."""

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason


@typing.final
class ShardCloseCode(int, enums.Enum):
    """Reasons for a shard connection closure."""

    NORMAL_CLOSURE = 1_000
    GOING_AWAY = 1_001
    PROTOCOL_ERROR = 1_002
    TYPE_ERROR = 1_003
    ENCODING_ERROR = 1_007
    POLICY_VIOLATION = 1_008
    TOO_BIG = 1_009
    UNEXPECTED_CONDITION = 1_011
    UNKNOWN_ERROR = 4_000
    UNKNOWN_OPCODE = 4_001
    DECODE_ERROR = 4_002
    NOT_AUTHENTICATED = 4_003
    AUTHENTICATION_FAILED = 4_004
    ALREADY_AUTHENTICATED = 4_005
    INVALID_SEQ = 4_007
    RATE_LIMITED = 4_008
    SESSION_TIMEOUT = 4_009
    INVALID_SHARD = 4_010
    SHARDING_REQUIRED = 4_011
    INVALID_VERSION = 4_012
    INVALID_INTENT = 4_013
    DISALLOWED_INTENT = 4_014

    @property
    def is_standard(self) -> bool:
        """Return `builtins.True` if this is a standard code."""
        return (self.value // 1000) == 1


@attr.define(auto_exc=True, repr=False, slots=False)
class GatewayConnectionError(GatewayError):
    """An exception thrown if a connection issue occurs."""

    def __str__(self) -> str:
        return f"Failed to connect to server: {self.reason!r}"


@attr.define(auto_exc=True, repr=False, slots=False)
class GatewayServerClosedConnectionError(GatewayError):
    """An exception raised when the server closes the connection."""

    code: typing.Union[ShardCloseCode, int, None] = attr.field(default=None)
    """Return the close code that was received, if there is one.

    Returns
    -------
    typing.Union[ShardCloseCode, builtins.int, builtins.None]
        The shard close code if there was one. Will be a `ShardCloseCode`
        if the definition is known. Undocumented close codes may instead be
        an `builtins.int` instead.

        If no close code was received, this will be `builtins.None`.
    """

    can_reconnect: bool = attr.field(default=False)
    """Return `builtins.True` if we can recover from this closure.

    If `builtins.True`, it will try to reconnect after this is raised rather
    than it being propagated to the caller. If `builtins.False`, this will
    be raised, thus stopping the application unless handled explicitly by the
    user.

    Returns
    -------
    builtins.bool
        Whether the closure can be recovered from via a reconnect.
    """

    def __str__(self) -> str:
        return f"Server closed connection with code {self.code} ({self.reason})"


@attr.define(auto_exc=True, repr=False, slots=False)
class HTTPError(HikariError):
    """Base exception raised if an HTTP error occurs while making a request."""

    message: str = attr.field()
    """The error message."""


@attr.define(auto_exc=True, repr=False, slots=False)
class HTTPResponseError(HTTPError):
    """Base exception for an erroneous HTTP response."""

    url: str = attr.field()
    """The URL that produced this error message."""

    status: typing.Union[http.HTTPStatus, int] = attr.field()
    """The HTTP status code for the response.

    This will be `int` if it's outside the range of status codes in the HTTP
    specification (e.g. one of Cloudflare's non-standard status codes).
    """

    headers: data_binding.Headers = attr.field()
    """The headers received in the error response."""

    raw_body: typing.Any = attr.field()
    """The response body."""

    message: str = attr.field(default="")
    """The error message."""

    code: int = attr.field(default=0)
    """The error code."""

    def __str__(self) -> str:
        if isinstance(self.status, http.HTTPStatus):
            name = self.status.name.replace("_", " ").title()
            name_value = f"{name} {self.status.value}"

        else:
            name_value = f"Unknown Status {self.status}"

        if self.code:
            code_str = f" ({self.code})"
        else:
            code_str = ""

        if self.message:
            body = self.message
        else:
            try:
                body = self.raw_body.decode("utf-8")
            except (AttributeError, UnicodeDecodeError, TypeError, ValueError):
                body = str(self.raw_body)

        chomped = len(body) > 200

        return f"{name_value}:{code_str} '{body[:200]}{'...' if chomped else ''}' for {self.url}"


@attr.define(auto_exc=True, repr=False, slots=False)
class ClientHTTPResponseError(HTTPResponseError):
    """Base exception for an erroneous HTTP response that is a client error.

    All exceptions derived from this base should be treated as 4xx client
    errors when encountered.
    """


def _dump_errors(obj: data_binding.JSONObject, obj_string: str = "") -> str:
    string = ""
    for key, value in obj.items():
        if isinstance(value, typing.Sequence):
            string += obj_string + ":"

            for item in value:
                string += f"\n - {item['message']}"

            string += "\n\n"

            continue

        current_obj_string = f"{obj_string}{'.' if obj_string else ''}{key}"
        string += _dump_errors(value, current_obj_string)

    return string


@attr.define(auto_exc=True, repr=False, slots=False)
class BadRequestError(ClientHTTPResponseError):
    """Raised when you send an invalid request somehow."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.BAD_REQUEST, init=False)
    """The HTTP status code for the response."""

    errors: typing.Optional[typing.Mapping[str, data_binding.JSONObject]] = attr.field(default=None, kw_only=True)
    """Dict of top level field names to field specific error paths.

    For more information, this error format is loosely defined at
    https://discord.com/developers/docs/reference#error-messages and is commonly
    returned for 50035 errors.
    """

    _cached_str: str = attr.field(default=None, init=False)

    def __str__(self) -> str:
        if self._cached_str:
            return self._cached_str

        value = super().__str__()
        if self.errors:
            value += "\n\n"

            try:
                value += _dump_errors(self.errors).strip("\n")
            except KeyError:
                value += data_binding.dump_json(self.errors, indent=2)

        self._cached_str = value
        return value


@attr.define(auto_exc=True, repr=False, slots=False)
class UnauthorizedError(ClientHTTPResponseError):
    """Raised when you are not authorized to access a specific resource."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.UNAUTHORIZED, init=False)
    """The HTTP status code for the response."""


@attr.define(auto_exc=True, repr=False, slots=False)
class ForbiddenError(ClientHTTPResponseError):
    """Raised when you are not allowed to access a specific resource.

    This means you lack the permissions to do something, either because of
    permissions set in a guild, or because your application is not whitelisted
    to use a specific endpoint.
    """

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.FORBIDDEN, init=False)
    """The HTTP status code for the response."""


@attr.define(auto_exc=True, repr=False, slots=False)
class NotFoundError(ClientHTTPResponseError):
    """Raised when something is not found."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.NOT_FOUND, init=False)
    """The HTTP status code for the response."""


@attr.define(auto_exc=True, kw_only=True, repr=False, slots=False)
class RateLimitedError(ClientHTTPResponseError):
    """Raised when a non-global rate limit that cannot be handled occurs.

    If you receive one of these, you should NOT try again until the given
    time has passed, either discarding the operation you performed, or waiting
    until the given time has passed first. Note that it may still be valid to
    send requests with different attributes in them.

    A use case for this by Discord appears to be to stop abuse from bots that
    change channel names, etc, regularly. This kind of action allegedly causes
    a fair amount of overhead internally for Discord. In the case you encounter
    this, you may be able to send different requests that manipulate the same
    entities (in this case editing the same channel) that do not use the same
    collection of attributes as the previous request.
    """

    route: routes.CompiledRoute = attr.field()
    """The route that produced this error."""

    retry_after: float = attr.field()
    """How many seconds to wait before you can reuse the route with the specific request."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.TOO_MANY_REQUESTS, init=False)
    """The HTTP status code for the response."""

    message: str = attr.field(init=False)
    """The error message."""

    @message.default
    def _(self) -> str:
        return f"You are being rate-limited for {self.retry_after:,} seconds on route {self.route}. Please slow down!"


@attr.define(auto_exc=True, kw_only=True, repr=False, slots=False)
class RateLimitTooLongError(HTTPError):
    """Internal error raised if the wait for a rate limit is too long.

    This is similar to `asyncio.TimeoutError` in the way that it is used,
    but this will be raised pre-emptively and immediately if the period
    of time needed to wait is greater than a user-defined limit.

    This will almost always be route-specific. If you receive this, it is
    unlikely that performing the same call for a different channel/guild/user
    will also have this rate limit.
    """

    route: routes.CompiledRoute = attr.field()
    """The route that produced this error."""

    retry_after: float = attr.field()
    """How many seconds to wait before you can retry this specific request."""

    max_retry_after: float = attr.field()
    """How long the client is allowed to wait for at a maximum before raising."""

    reset_at: float = attr.field()
    """UNIX timestamp of when this limit will be lifted."""

    limit: int = attr.field()
    """The maximum number of calls per window for this rate limit."""

    period: float = attr.field()
    """How long the rate limit window lasts for from start to end."""

    message: str = attr.field(init=False)
    """The error message."""

    @message.default
    def _(self) -> str:
        return (
            "The request has been rejected, as you would be waiting for more than"
            f"the max retry-after ({self.max_retry_after}) on route {self.route}"
        )

    # This may support other types of limits in the future, this currently
    # exists to be self-documenting to the user and for future compatibility
    # only.
    @property
    def remaining(self) -> typing.Literal[0]:
        """The number of requests remaining in this window.

        This will always be `0` symbolically.

        Returns
        -------
        builtins.int
            The number of requests remaining. Always `0`.
        """  # noqa: D401 - Imperative mood
        return 0

    def __str__(self) -> str:
        return self.message


@attr.define(auto_exc=True, repr=False, slots=False)
class InternalServerError(HTTPResponseError):
    """Base exception for an erroneous HTTP response that is a server error.

    All exceptions derived from this base should be treated as 5xx server
    errors when encountered. If you get one of these, it is not your fault!
    """


@attr.define(auto_exc=True, repr=False, init=False, slots=False)
class MissingIntentWarning(HikariWarning):
    """Warning raised when subscribing to an event that cannot be fired.

    This is caused by your application missing certain intents.
    """


@attr.define(auto_exc=True, repr=False, slots=False)
class BulkDeleteError(HikariError):
    """Exception raised when a bulk delete fails midway through a call.

    This will contain the list of message items that failed to be deleted,
    and will have a cause containing the initial exception.
    """

    messages_deleted: snowflakes.SnowflakeishSequence[messages.PartialMessage] = attr.field()
    """Any message objects that were deleted before an exception occurred."""

    messages_skipped: snowflakes.SnowflakeishSequence[messages.PartialMessage] = attr.field()
    """Any message objects that were skipped due to an exception."""

    @property
    def percentage_completion(self) -> float:
        """Return the percentage completion of the bulk delete before it failed.

        Returns
        -------
        builtins.float
            A percentage completion between 0 and 100 inclusive.
        """
        deleted = len(self.messages_deleted)
        total = deleted + len(self.messages_skipped)
        return 100 * deleted / total

    def __str__(self) -> str:
        deleted = len(self.messages_deleted)
        total = deleted + len(self.messages_skipped)
        return f"Error encountered when bulk deleting messages ({deleted}/{total} messages deleted)"


@attr.define(auto_exc=True, repr=False, init=False, slots=False)
class VoiceError(HikariError):
    """Error raised when a problem occurs with the voice subsystem."""


@attr.define(auto_exc=True, repr=False, slots=False)
class MissingIntentError(HikariError, ValueError):
    """Error raised when you try to perform an action without an intent.

    This is usually raised when querying the cache for something that is
    unavailable due to certain intents being disabled.
    """

    intents: intents_.Intents = attr.field()
    """The combination of intents that are missing."""

    def __str__(self) -> str:
        return "You are missing the following intent(s): " + ", ".join(map(str, self.intents.split()))

Classes

dataclass BadRequestError

class BadRequestError (
    url: str,
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
    *,
    errors: Optional[Mapping[strdata_binding.JSONObject]] = None,
): ...

Raised when you send an invalid request somehow.

Method generated by attrs for class BadRequestError.

Expand source code
Browse git
class BadRequestError(ClientHTTPResponseError):
    """Raised when you send an invalid request somehow."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.BAD_REQUEST, init=False)
    """The HTTP status code for the response."""

    errors: typing.Optional[typing.Mapping[str, data_binding.JSONObject]] = attr.field(default=None, kw_only=True)
    """Dict of top level field names to field specific error paths.

    For more information, this error format is loosely defined at
    https://discord.com/developers/docs/reference#error-messages and is commonly
    returned for 50035 errors.
    """

    _cached_str: str = attr.field(default=None, init=False)

    def __str__(self) -> str:
        if self._cached_str:
            return self._cached_str

        value = super().__str__()
        if self.errors:
            value += "\n\n"

            try:
                value += _dump_errors(self.errors).strip("\n")
            except KeyError:
                value += data_binding.dump_json(self.errors, indent=2)

        self._cached_str = value
        return value
Method resolution order
dataclass BadRequestError
That's this class!
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var errors : Optional[Mapping[str, Mapping[str, Any]]]

Dict of top level field names to field specific error paths.

For more information, this error format is loosely defined at https://discord.com/developers/docs/reference#error-messages and is commonly returned for 50035 errors.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var statushttp.HTTPStatus

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass BulkDeleteError

class BulkDeleteError (
    messages_deleted: snowflakes.SnowflakeishSequence[messages.PartialMessage],
    messages_skipped: snowflakes.SnowflakeishSequence[messages.PartialMessage],
): ...

Exception raised when a bulk delete fails midway through a call.

This will contain the list of message items that failed to be deleted, and will have a cause containing the initial exception.

Method generated by attrs for class BulkDeleteError.

Expand source code
Browse git
class BulkDeleteError(HikariError):
    """Exception raised when a bulk delete fails midway through a call.

    This will contain the list of message items that failed to be deleted,
    and will have a cause containing the initial exception.
    """

    messages_deleted: snowflakes.SnowflakeishSequence[messages.PartialMessage] = attr.field()
    """Any message objects that were deleted before an exception occurred."""

    messages_skipped: snowflakes.SnowflakeishSequence[messages.PartialMessage] = attr.field()
    """Any message objects that were skipped due to an exception."""

    @property
    def percentage_completion(self) -> float:
        """Return the percentage completion of the bulk delete before it failed.

        Returns
        -------
        builtins.float
            A percentage completion between 0 and 100 inclusive.
        """
        deleted = len(self.messages_deleted)
        total = deleted + len(self.messages_skipped)
        return 100 * deleted / total

    def __str__(self) -> str:
        deleted = len(self.messages_deleted)
        total = deleted + len(self.messages_skipped)
        return f"Error encountered when bulk deleting messages ({deleted}/{total} messages deleted)"
Method resolution order
dataclass BulkDeleteError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
property percentage_completionfloat

Return the percentage completion of the bulk delete before it failed.

Returns

float
A percentage completion between 0 and 100 inclusive.
var messages_deletedsnowflakes.SnowflakeishSequence[messages.PartialMessage]

Any message objects that were deleted before an exception occurred.

var messages_skippedsnowflakes.SnowflakeishSequence[messages.PartialMessage]

Any message objects that were skipped due to an exception.

dataclass ClientHTTPResponseError

class ClientHTTPResponseError (
    url: str,
    status: Union[http.HTTPStatusint],
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Base exception for an erroneous HTTP response that is a client error.

All exceptions derived from this base should be treated as 4xx client errors when encountered.

Method generated by attrs for class ClientHTTPResponseError.

Expand source code
Browse git
class ClientHTTPResponseError(HTTPResponseError):
    """Base exception for an erroneous HTTP response that is a client error.

    All exceptions derived from this base should be treated as 4xx client
    errors when encountered.
    """
Subclasses
dataclass BadRequestError

Raised when you send an invalid request somehow …

dataclass ForbiddenError

Raised when you are not allowed to access a specific resource …

dataclass NotFoundError

Raised when something is not found …

dataclass RateLimitedError

Raised when a non-global rate limit that cannot be handled occurs …

dataclass UnauthorizedError

Raised when you are not authorized to access a specific resource …

Method resolution order
dataclass ClientHTTPResponseError
That's this class!
dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var status : Union[http.HTTPStatusint]

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass ComponentStateConflictError

class ComponentStateConflictError (
    reason: str,
): ...

Exception thrown when an action cannot be executed in the component's current state.

Dependent on context this will be thrown for components which are already running or haven't been started yet.

Method generated by attrs for class ComponentStateConflictError.

Expand source code
Browse git
class ComponentStateConflictError(HikariError):
    """Exception thrown when an action cannot be executed in the component's current state.

    Dependent on context this will be thrown for components which are already
    running or haven't been started yet.
    """

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason
Method resolution order
dataclass ComponentStateConflictError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var reasonstr

A string to explain the issue.

dataclass ForbiddenError

class ForbiddenError (
    url: str,
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Raised when you are not allowed to access a specific resource.

This means you lack the permissions to do something, either because of permissions set in a guild, or because your application is not whitelisted to use a specific endpoint.

Method generated by attrs for class ForbiddenError.

Expand source code
Browse git
class ForbiddenError(ClientHTTPResponseError):
    """Raised when you are not allowed to access a specific resource.

    This means you lack the permissions to do something, either because of
    permissions set in a guild, or because your application is not whitelisted
    to use a specific endpoint.
    """

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.FORBIDDEN, init=False)
    """The HTTP status code for the response."""
Method resolution order
dataclass ForbiddenError
That's this class!
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var statushttp.HTTPStatus

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass GatewayConnectionError

class GatewayConnectionError (
    reason: str,
): ...

An exception thrown if a connection issue occurs.

Method generated by attrs for class GatewayConnectionError.

Expand source code
Browse git
class GatewayConnectionError(GatewayError):
    """An exception thrown if a connection issue occurs."""

    def __str__(self) -> str:
        return f"Failed to connect to server: {self.reason!r}"
Method resolution order
dataclass GatewayConnectionError
That's this class!
dataclass GatewayError

A base exception type for anything that can be thrown by the Gateway …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var reasonstr

A string to explain the issue.

dataclass GatewayError

class GatewayError (
    reason: str,
): ...

A base exception type for anything that can be thrown by the Gateway.

Method generated by attrs for class GatewayError.

Expand source code
Browse git
class GatewayError(HikariError):
    """A base exception type for anything that can be thrown by the Gateway."""

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason
Subclasses
dataclass GatewayConnectionError

An exception thrown if a connection issue occurs …

dataclass GatewayServerClosedConnectionError

An exception raised when the server closes the connection …

Method resolution order
dataclass GatewayError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var reasonstr

A string to explain the issue.

dataclass GatewayServerClosedConnectionError

class GatewayServerClosedConnectionError (
    reason: str,
    code: Union[ShardCloseCodeintNone] = None,
    can_reconnect: bool = False,
): ...

An exception raised when the server closes the connection.

Method generated by attrs for class GatewayServerClosedConnectionError.

Expand source code
Browse git
class GatewayServerClosedConnectionError(GatewayError):
    """An exception raised when the server closes the connection."""

    code: typing.Union[ShardCloseCode, int, None] = attr.field(default=None)
    """Return the close code that was received, if there is one.

    Returns
    -------
    typing.Union[ShardCloseCode, builtins.int, builtins.None]
        The shard close code if there was one. Will be a `ShardCloseCode`
        if the definition is known. Undocumented close codes may instead be
        an `builtins.int` instead.

        If no close code was received, this will be `builtins.None`.
    """

    can_reconnect: bool = attr.field(default=False)
    """Return `builtins.True` if we can recover from this closure.

    If `builtins.True`, it will try to reconnect after this is raised rather
    than it being propagated to the caller. If `builtins.False`, this will
    be raised, thus stopping the application unless handled explicitly by the
    user.

    Returns
    -------
    builtins.bool
        Whether the closure can be recovered from via a reconnect.
    """

    def __str__(self) -> str:
        return f"Server closed connection with code {self.code} ({self.reason})"
Method resolution order
dataclass GatewayServerClosedConnectionError
That's this class!
dataclass GatewayError

A base exception type for anything that can be thrown by the Gateway …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var can_reconnectbool

Return True if we can recover from this closure.

If True, it will try to reconnect after this is raised rather than it being propagated to the caller. If False, this will be raised, thus stopping the application unless handled explicitly by the user.

Returns

bool
Whether the closure can be recovered from via a reconnect.
var code : Union[ShardCloseCodeintNone]

Return the close code that was received, if there is one.

Returns

Union[ShardCloseCode, int, None]

The shard close code if there was one. Will be a ShardCloseCode if the definition is known. Undocumented close codes may instead be an int instead.

If no close code was received, this will be None.

var reasonstr

A string to explain the issue.

dataclass HTTPError

class HTTPError (
    message: str,
): ...

Base exception raised if an HTTP error occurs while making a request.

Method generated by attrs for class HTTPError.

Expand source code
Browse git
class HTTPError(HikariError):
    """Base exception raised if an HTTP error occurs while making a request."""

    message: str = attr.field()
    """The error message."""
Subclasses
dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass RateLimitTooLongError

Internal error raised if the wait for a rate limit is too long …

Method resolution order
dataclass HTTPError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var messagestr

The error message.

dataclass HTTPResponseError

class HTTPResponseError (
    url: str,
    status: Union[http.HTTPStatusint],
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Base exception for an erroneous HTTP response.

Method generated by attrs for class HTTPResponseError.

Expand source code
Browse git
class HTTPResponseError(HTTPError):
    """Base exception for an erroneous HTTP response."""

    url: str = attr.field()
    """The URL that produced this error message."""

    status: typing.Union[http.HTTPStatus, int] = attr.field()
    """The HTTP status code for the response.

    This will be `int` if it's outside the range of status codes in the HTTP
    specification (e.g. one of Cloudflare's non-standard status codes).
    """

    headers: data_binding.Headers = attr.field()
    """The headers received in the error response."""

    raw_body: typing.Any = attr.field()
    """The response body."""

    message: str = attr.field(default="")
    """The error message."""

    code: int = attr.field(default=0)
    """The error code."""

    def __str__(self) -> str:
        if isinstance(self.status, http.HTTPStatus):
            name = self.status.name.replace("_", " ").title()
            name_value = f"{name} {self.status.value}"

        else:
            name_value = f"Unknown Status {self.status}"

        if self.code:
            code_str = f" ({self.code})"
        else:
            code_str = ""

        if self.message:
            body = self.message
        else:
            try:
                body = self.raw_body.decode("utf-8")
            except (AttributeError, UnicodeDecodeError, TypeError, ValueError):
                body = str(self.raw_body)

        chomped = len(body) > 200

        return f"{name_value}:{code_str} '{body[:200]}{'...' if chomped else ''}' for {self.url}"
Subclasses
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass InternalServerError

Base exception for an erroneous HTTP response that is a server error …

Method resolution order
dataclass HTTPResponseError
That's this class!
dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var status : Union[http.HTTPStatusint]

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass HikariError

class HikariError (
    *args,
    **kwargs,
): ...

Base for an error raised by this API.

Any exceptions should derive from this.

Note

You should never initialize this exception directly.

Expand source code
Browse git
class HikariError(RuntimeError):
    """Base for an error raised by this API.

    Any exceptions should derive from this.

    !!! note
        You should never initialize this exception directly.
    """
Subclasses
dataclass BulkDeleteError

Exception raised when a bulk delete fails midway through a call …

dataclass ComponentStateConflictError

Exception thrown when an action cannot be executed in the component's current state …

dataclass GatewayError

A base exception type for anything that can be thrown by the Gateway …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariInterrupt

Exception raised when a kill signal is handled internally …

dataclass MissingIntentError

Error raised when you try to perform an action without an intent …

dataclass UnrecognisedEntityError

An exception thrown when an unrecognised entity is found …

dataclass VoiceError

Error raised when a problem occurs with the voice subsystem.

Method resolution order
dataclass HikariError
That's this class!
extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

dataclass HikariInterrupt

class HikariInterrupt (
    signum: int,
    signame: str,
): ...

Exception raised when a kill signal is handled internally.

Method generated by attrs for class HikariInterrupt.

Expand source code
Browse git
class HikariInterrupt(KeyboardInterrupt, HikariError):
    """Exception raised when a kill signal is handled internally."""

    signum: int = attr.field()
    """The signal number that was raised."""

    signame: str = attr.field()
    """The signal name that was raised."""
Method resolution order
dataclass HikariInterrupt
That's this class!
extern class KeyboardInterrupt

Program interrupted by user.

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var signamestr

The signal name that was raised.

var signumint

The signal number that was raised.

dataclass HikariWarning

class HikariWarning (
    *args,
    **kwargs,
): ...

Base for a warning raised by this API.

Any warnings should derive from this.

Note

You should never initialize this warning directly.

Expand source code
Browse git
class HikariWarning(RuntimeWarning):
    """Base for a warning raised by this API.

    Any warnings should derive from this.

    !!! note
        You should never initialize this warning directly.
    """
Subclasses
dataclass MissingIntentWarning

Warning raised when subscribing to an event that cannot be fired …

Method resolution order
dataclass HikariWarning
That's this class!
extern class RuntimeWarning

Base class for warnings about dubious runtime behavior.

extern class Warning

Base class for warning categories.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

dataclass InternalServerError

class InternalServerError (
    url: str,
    status: Union[http.HTTPStatusint],
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Base exception for an erroneous HTTP response that is a server error.

All exceptions derived from this base should be treated as 5xx server errors when encountered. If you get one of these, it is not your fault!

Method generated by attrs for class InternalServerError.

Expand source code
Browse git
class InternalServerError(HTTPResponseError):
    """Base exception for an erroneous HTTP response that is a server error.

    All exceptions derived from this base should be treated as 5xx server
    errors when encountered. If you get one of these, it is not your fault!
    """
Method resolution order
dataclass InternalServerError
That's this class!
dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var status : Union[http.HTTPStatusint]

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass MissingIntentError

class MissingIntentError (
    intents: intents_.Intents,
): ...

Error raised when you try to perform an action without an intent.

This is usually raised when querying the cache for something that is unavailable due to certain intents being disabled.

Method generated by attrs for class MissingIntentError.

Expand source code
Browse git
class MissingIntentError(HikariError, ValueError):
    """Error raised when you try to perform an action without an intent.

    This is usually raised when querying the cache for something that is
    unavailable due to certain intents being disabled.
    """

    intents: intents_.Intents = attr.field()
    """The combination of intents that are missing."""

    def __str__(self) -> str:
        return "You are missing the following intent(s): " + ", ".join(map(str, self.intents.split()))
Method resolution order
dataclass MissingIntentError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class ValueError

Inappropriate argument value (of correct type).

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var intentsintents_.Intents

The combination of intents that are missing.

dataclass MissingIntentWarning

class MissingIntentWarning (
    *args,
    **kwargs,
): ...

Warning raised when subscribing to an event that cannot be fired.

This is caused by your application missing certain intents.

Expand source code
Browse git
class MissingIntentWarning(HikariWarning):
    """Warning raised when subscribing to an event that cannot be fired.

    This is caused by your application missing certain intents.
    """
Method resolution order
dataclass MissingIntentWarning
That's this class!
dataclass HikariWarning

Base for a warning raised by this API …

extern class RuntimeWarning

Base class for warnings about dubious runtime behavior.

extern class Warning

Base class for warning categories.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

dataclass NotFoundError

class NotFoundError (
    url: str,
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Raised when something is not found.

Method generated by attrs for class NotFoundError.

Expand source code
Browse git
class NotFoundError(ClientHTTPResponseError):
    """Raised when something is not found."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.NOT_FOUND, init=False)
    """The HTTP status code for the response."""
Method resolution order
dataclass NotFoundError
That's this class!
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var statushttp.HTTPStatus

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass RateLimitTooLongError

class RateLimitTooLongError (
    *,
    route: routes.CompiledRoute,
    retry_after: float,
    max_retry_after: float,
    reset_at: float,
    limit: int,
    period: float,
): ...

Internal error raised if the wait for a rate limit is too long.

This is similar to TimeoutError in the way that it is used, but this will be raised pre-emptively and immediately if the period of time needed to wait is greater than a user-defined limit.

This will almost always be route-specific. If you receive this, it is unlikely that performing the same call for a different channel/guild/user will also have this rate limit.

Method generated by attrs for class RateLimitTooLongError.

Expand source code
Browse git
class RateLimitTooLongError(HTTPError):
    """Internal error raised if the wait for a rate limit is too long.

    This is similar to `asyncio.TimeoutError` in the way that it is used,
    but this will be raised pre-emptively and immediately if the period
    of time needed to wait is greater than a user-defined limit.

    This will almost always be route-specific. If you receive this, it is
    unlikely that performing the same call for a different channel/guild/user
    will also have this rate limit.
    """

    route: routes.CompiledRoute = attr.field()
    """The route that produced this error."""

    retry_after: float = attr.field()
    """How many seconds to wait before you can retry this specific request."""

    max_retry_after: float = attr.field()
    """How long the client is allowed to wait for at a maximum before raising."""

    reset_at: float = attr.field()
    """UNIX timestamp of when this limit will be lifted."""

    limit: int = attr.field()
    """The maximum number of calls per window for this rate limit."""

    period: float = attr.field()
    """How long the rate limit window lasts for from start to end."""

    message: str = attr.field(init=False)
    """The error message."""

    @message.default
    def _(self) -> str:
        return (
            "The request has been rejected, as you would be waiting for more than"
            f"the max retry-after ({self.max_retry_after}) on route {self.route}"
        )

    # This may support other types of limits in the future, this currently
    # exists to be self-documenting to the user and for future compatibility
    # only.
    @property
    def remaining(self) -> typing.Literal[0]:
        """The number of requests remaining in this window.

        This will always be `0` symbolically.

        Returns
        -------
        builtins.int
            The number of requests remaining. Always `0`.
        """  # noqa: D401 - Imperative mood
        return 0

    def __str__(self) -> str:
        return self.message
Method resolution order
dataclass RateLimitTooLongError
That's this class!
dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
property remaining : Literal[0]

The number of requests remaining in this window.

This will always be 0 symbolically.

Returns

int
The number of requests remaining. Always 0.
var limitint

The maximum number of calls per window for this rate limit.

var max_retry_afterfloat

How long the client is allowed to wait for at a maximum before raising.

var messagestr

The error message.

var periodfloat

How long the rate limit window lasts for from start to end.

var reset_atfloat

UNIX timestamp of when this limit will be lifted.

var retry_afterfloat

How many seconds to wait before you can retry this specific request.

var routeroutes.CompiledRoute

The route that produced this error.

dataclass RateLimitedError

class RateLimitedError (
    *,
    url: str,
    headers: data_binding.Headers,
    raw_body: Any,
    code: int = 0,
    route: routes.CompiledRoute,
    retry_after: float,
): ...

Raised when a non-global rate limit that cannot be handled occurs.

If you receive one of these, you should NOT try again until the given time has passed, either discarding the operation you performed, or waiting until the given time has passed first. Note that it may still be valid to send requests with different attributes in them.

A use case for this by Discord appears to be to stop abuse from bots that change channel names, etc, regularly. This kind of action allegedly causes a fair amount of overhead internally for Discord. In the case you encounter this, you may be able to send different requests that manipulate the same entities (in this case editing the same channel) that do not use the same collection of attributes as the previous request.

Method generated by attrs for class RateLimitedError.

Expand source code
Browse git
class RateLimitedError(ClientHTTPResponseError):
    """Raised when a non-global rate limit that cannot be handled occurs.

    If you receive one of these, you should NOT try again until the given
    time has passed, either discarding the operation you performed, or waiting
    until the given time has passed first. Note that it may still be valid to
    send requests with different attributes in them.

    A use case for this by Discord appears to be to stop abuse from bots that
    change channel names, etc, regularly. This kind of action allegedly causes
    a fair amount of overhead internally for Discord. In the case you encounter
    this, you may be able to send different requests that manipulate the same
    entities (in this case editing the same channel) that do not use the same
    collection of attributes as the previous request.
    """

    route: routes.CompiledRoute = attr.field()
    """The route that produced this error."""

    retry_after: float = attr.field()
    """How many seconds to wait before you can reuse the route with the specific request."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.TOO_MANY_REQUESTS, init=False)
    """The HTTP status code for the response."""

    message: str = attr.field(init=False)
    """The error message."""

    @message.default
    def _(self) -> str:
        return f"You are being rate-limited for {self.retry_after:,} seconds on route {self.route}. Please slow down!"
Method resolution order
dataclass RateLimitedError
That's this class!
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headersdata_binding.Headers

The headers received in the error response.

var messagestr

The error message.

var raw_bodyAny

The response body.

var retry_afterfloat

How many seconds to wait before you can reuse the route with the specific request.

var routeroutes.CompiledRoute

The route that produced this error.

var statushttp.HTTPStatus

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

enum ShardCloseCode

class ShardCloseCode (
    value: Any,
): ...

Reasons for a shard connection closure.

Expand source code
Browse git
class ShardCloseCode(int, enums.Enum):
    """Reasons for a shard connection closure."""

    NORMAL_CLOSURE = 1_000
    GOING_AWAY = 1_001
    PROTOCOL_ERROR = 1_002
    TYPE_ERROR = 1_003
    ENCODING_ERROR = 1_007
    POLICY_VIOLATION = 1_008
    TOO_BIG = 1_009
    UNEXPECTED_CONDITION = 1_011
    UNKNOWN_ERROR = 4_000
    UNKNOWN_OPCODE = 4_001
    DECODE_ERROR = 4_002
    NOT_AUTHENTICATED = 4_003
    AUTHENTICATION_FAILED = 4_004
    ALREADY_AUTHENTICATED = 4_005
    INVALID_SEQ = 4_007
    RATE_LIMITED = 4_008
    SESSION_TIMEOUT = 4_009
    INVALID_SHARD = 4_010
    SHARDING_REQUIRED = 4_011
    INVALID_VERSION = 4_012
    INVALID_INTENT = 4_013
    DISALLOWED_INTENT = 4_014

    @property
    def is_standard(self) -> bool:
        """Return `builtins.True` if this is a standard code."""
        return (self.value // 1000) == 1
Method resolution order
enum ShardCloseCode
That's this class!
extern class int

int([x]) -> integer int(x, base=10) -> integer …

enum Enum

Clone of Python's enum.Enum implementation …

Variables and properties
property is_standardbool

Return True if this is a standard code.

property namestr

Return the name of the enum member as a str.

property value

Return the value of the enum member.

const ALREADY_AUTHENTICATED = 4005
const AUTHENTICATION_FAILED = 4004
const DECODE_ERROR = 4002
const DISALLOWED_INTENT = 4014
const ENCODING_ERROR = 1007
const GOING_AWAY = 1001
const INVALID_INTENT = 4013
const INVALID_SEQ = 4007
const INVALID_SHARD = 4010
const INVALID_VERSION = 4012
const NORMAL_CLOSURE = 1000
const NOT_AUTHENTICATED = 4003
const POLICY_VIOLATION = 1008
const PROTOCOL_ERROR = 1002
const RATE_LIMITED = 4008
const SESSION_TIMEOUT = 4009
const SHARDING_REQUIRED = 4011
const TOO_BIG = 1009
const TYPE_ERROR = 1003
const UNEXPECTED_CONDITION = 1011
const UNKNOWN_ERROR = 4000
const UNKNOWN_OPCODE = 4001

dataclass UnauthorizedError

class UnauthorizedError (
    url: str,
    headers: data_binding.Headers,
    raw_body: Any,
    message: str = '',
    code: int = 0,
): ...

Raised when you are not authorized to access a specific resource.

Method generated by attrs for class UnauthorizedError.

Expand source code
Browse git
class UnauthorizedError(ClientHTTPResponseError):
    """Raised when you are not authorized to access a specific resource."""

    status: http.HTTPStatus = attr.field(default=http.HTTPStatus.UNAUTHORIZED, init=False)
    """The HTTP status code for the response."""
Method resolution order
dataclass UnauthorizedError
That's this class!
dataclass ClientHTTPResponseError

Base exception for an erroneous HTTP response that is a client error …

dataclass HTTPResponseError

Base exception for an erroneous HTTP response …

dataclass HTTPError

Base exception raised if an HTTP error occurs while making a request …

dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var codeint

The error code.

var headers : Mapping[strstr]

The headers received in the error response.

var messagestr

The error message.

var raw_body : Any

The response body.

var statushttp.HTTPStatus

The HTTP status code for the response.

This will be int if it's outside the range of status codes in the HTTP specification (e.g. one of Cloudflare's non-standard status codes).

var urlstr

The URL that produced this error message.

dataclass UnrecognisedEntityError

class UnrecognisedEntityError (
    reason: str,
): ...

An exception thrown when an unrecognised entity is found.

Method generated by attrs for class UnrecognisedEntityError.

Expand source code
Browse git
class UnrecognisedEntityError(HikariError):
    """An exception thrown when an unrecognised entity is found."""

    reason: str = attr.field()
    """A string to explain the issue."""

    def __str__(self) -> str:
        return self.reason
Method resolution order
dataclass UnrecognisedEntityError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions

Variables and properties
var reasonstr

A string to explain the issue.

dataclass VoiceError

class VoiceError (
    *args,
    **kwargs,
): ...

Error raised when a problem occurs with the voice subsystem.

Expand source code
Browse git
class VoiceError(HikariError):
    """Error raised when a problem occurs with the voice subsystem."""
Method resolution order
dataclass VoiceError
That's this class!
dataclass HikariError

Base for an error raised by this API …

extern class RuntimeError

Unspecified run-time error.

extern class Exception

Common base class for all non-exit exceptions.

extern class BaseException

Common base class for all exceptions