Skip to content

hikari.errors#

Exceptions and warnings that can be thrown by this library.

BadRequestError #

Bases: ClientHTTPResponseError

Raised when you send an invalid request somehow.

errors class-attribute instance-attribute #

errors: Optional[Mapping[str, JSONObject]] = 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.

status class-attribute instance-attribute #

status: HTTPStatus = field(default=BAD_REQUEST, init=False)

The HTTP status code for the response.

BulkDeleteError #

Bases: 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.

deleted_messages class-attribute instance-attribute #

deleted_messages: SnowflakeishSequence[PartialMessage] = field()

Any message objects that were deleted before an exception occurred.

ClientHTTPResponseError #

Bases: 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.

ComponentStateConflictError #

Bases: 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 class-attribute instance-attribute #

reason: str = field()

A string to explain the issue.

ForbiddenError #

Bases: 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 class-attribute instance-attribute #

status: HTTPStatus = field(default=FORBIDDEN, init=False)

The HTTP status code for the response.

GatewayConnectionError #

Bases: GatewayError

An exception thrown if a connection issue occurs.

GatewayError #

Bases: HikariError

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

reason class-attribute instance-attribute #

reason: str = field()

A string to explain the issue.

GatewayServerClosedConnectionError #

Bases: GatewayError

An exception raised when the server closes the connection.

can_reconnect class-attribute instance-attribute #

can_reconnect: bool = field(default=False)

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.

code class-attribute instance-attribute #

code: Union[ShardCloseCode, int, None] = field(default=None)

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

GatewayTransportError #

Bases: GatewayError

An exception thrown if an issue occurs at the transport layer.

HTTPError #

Bases: HikariError

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

message class-attribute instance-attribute #

message: str = field()

The error message.

HTTPResponseError #

Bases: HTTPError

Base exception for an erroneous HTTP response.

code class-attribute instance-attribute #

code: int = field(default=0)

The error code.

headers class-attribute instance-attribute #

headers: Headers = field()

The headers received in the error response.

message class-attribute instance-attribute #

message: str = field(default='')

The error message.

raw_body class-attribute instance-attribute #

raw_body: Any = field()

The response body.

status class-attribute instance-attribute #

status: Union[HTTPStatus, int] = 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).

url class-attribute instance-attribute #

url: str = field()

The URL that produced this error message.

HikariError #

Bases: RuntimeError

Base for an error raised by this API.

Any exceptions should derive from this.

Note

You should never initialize this exception directly.

HikariInterrupt #

Bases: KeyboardInterrupt, HikariError

Exception raised when a kill signal is handled internally.

signame class-attribute instance-attribute #

signame: str = field()

The signal name that was raised.

signum class-attribute instance-attribute #

signum: int = field()

The signal number that was raised.

HikariWarning #

Bases: RuntimeWarning

Base for a warning raised by this API.

Any warnings should derive from this.

Note

You should never initialize this warning directly.

InternalServerError #

Bases: 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!

MissingIntentError #

Bases: 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 class-attribute instance-attribute #

intents: Intents = field()

The combination of intents that are missing.

MissingIntentWarning #

Bases: HikariWarning

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

This is caused by your application missing certain intents.

NotFoundError #

Bases: ClientHTTPResponseError

Raised when something is not found.

status class-attribute instance-attribute #

status: HTTPStatus = field(default=NOT_FOUND, init=False)

The HTTP status code for the response.

RateLimitTooLongError #

Bases: 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.

is_global class-attribute instance-attribute #

is_global: bool = field()

Whether the ratelimit is global.

limit class-attribute instance-attribute #

limit: Optional[int] = field()

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

max_retry_after class-attribute instance-attribute #

max_retry_after: float = field()

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

message class-attribute instance-attribute #

message: str = field(init=False)

The error message.

period class-attribute instance-attribute #

period: Optional[float] = field()

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

remaining property #

remaining: Literal[0]

Remaining requests in this window.

This will always be 0 symbolically.

reset_at class-attribute instance-attribute #

reset_at: float = field()

UNIX timestamp of when this limit will be lifted.

retry_after class-attribute instance-attribute #

retry_after: float = field()

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

route class-attribute instance-attribute #

route: CompiledRoute = field()

The route that produced this error.

ShardCloseCode #

Bases: int, Enum

Reasons for a shard connection closure.

is_standard property #

is_standard: bool

Return True if this is a standard code.

UnauthorizedError #

Bases: ClientHTTPResponseError

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

status class-attribute instance-attribute #

status: HTTPStatus = field(default=UNAUTHORIZED, init=False)

The HTTP status code for the response.

UnrecognisedEntityError #

Bases: HikariError

An exception thrown when an unrecognised entity is found.

reason class-attribute instance-attribute #

reason: str = field()

A string to explain the issue.

VoiceError #

Bases: HikariError

Error raised when a problem occurs with the voice subsystem.