Skip to content

tanjun.errors#

The errors and warnings raised within and by Tanjun.

MissingDependencyError module-attribute #

MissingDependencyError = MissingDependencyError

CommandError #

Bases: TanjunError

An error which is sent as a response to the command call.

attachments instance-attribute #

attachments = [attachment] if attachment else attachments

Sequence of the attachments to be sent as a response to the command, if set.

components instance-attribute #

components = [component] if component else components

Sequence of the components to be sent as a response to the command, if set.

content instance-attribute #

content = content

The response error message's content.

delete_after instance-attribute #

delete_after = delete_after

The seconds after which the response message should be deleted, if set.

embeds instance-attribute #

embeds = [embed] if embed else embeds

Sequence of the embeds to be sent as a response to the command, if set.

mentions_everyone instance-attribute #

mentions_everyone = mentions_everyone

Whether or not the response should be allowed to mention @everyone/@here.

role_mentions instance-attribute #

role_mentions = role_mentions

Configuration for the response's allowed role mentions.

If this is a sequence then the response will only be allowed to mention roles in the sequence.

If this is a bool then the response will only be allowed to mention roles if the value is True.

user_mentions instance-attribute #

user_mentions = user_mentions

Configuration for the response's allowed user mentions.

If this is a sequence then the response will only be allowed to mention users in the sequence.

If this is a bool then the response will only be allowed to mention users if the value is True.

__init__ #

__init__(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)

Initialise a command error.

Parameters:

Raises:

  • ValueError

    Raised for any of the following reasons:

    • When both attachment and attachments are provided.
    • When both component and components are passed.
    • When both embed and embeds are passed.
    • If more than 100 entries are passed for role_mentions.
    • If more than 100 entries are passed for user_mentions.

send async #

send(ctx: tanjun.Context, /, *, ensure_result: typing.Literal[True]) -> hikari.Message
send(ctx: tanjun.Context, /, *, ensure_result: bool = False) -> hikari.Message | None
send(ctx, /, *, ensure_result=False)

Send this error as a command response.

Parameters:

  • ctx (Context) –

    The command call context to respond to.

  • ensure_result (bool, default: False ) –

    Ensure that this call will always return a message object.

    If True then this will always return hikari.Message, otherwise this will return hikari.Message | None.

    It's worth noting that, under certain scenarios within the slash command flow, this may lead to an extre request being made.

Raises:

  • ValueError

    If delete_after would be more than 15 minutes after the slash command was called.

  • BadRequestError

    This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.

  • UnauthorizedError

    If you are unauthorized to make the request (invalid/missing token).

  • ForbiddenError

    If you are missing the SEND_MESSAGES in the channel or the person you are trying to message has the DM's disabled.

  • NotFoundError

    If the channel is not found.

  • RateLimitTooLongError

    Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

  • InternalServerError

    If an internal error occurs on Discord while handling the request.

ConversionError #

Bases: ParserError

Error raised by a parser parameter when it failed to converter a value.

errors instance-attribute #

errors = tuple(errors)

Sequence of the errors that were caught during conversion for this parameter.

message instance-attribute #

message = message

String message for this error.

Note

This may be used as a command response message.

parameter instance-attribute #

parameter

Name of the parameter this error was raised for.

__init__ #

__init__(message, parameter, /, *, errors=())

Initialise a conversion error.

Parameters:

  • parameter (str) –

    The parameter this was raised by.

  • errors (Iterable[ValueError], default: () ) –

    An iterable of the source value errors which were raised during conversion.

FailedCheck #

Bases: TanjunError, RuntimeError

Error raised as an alternative to returning False in a check.

FailedModuleImport #

Bases: FailedModuleLoad

Error raised when a module failed to import.

This is a specialisation of FailedModuleLoad.

__cause__ instance-attribute #

__cause__

The root error.

path property #

path

The path of the module which caused the error.

FailedModuleLoad #

Bases: TanjunError

Error raised when a module fails to load.

This may be raised by the module failing to import or by one of its loaders erroring.

This source error can be accessed at FailedModuleLoad.__cause__.

__cause__ instance-attribute #

__cause__

The root error.

path property #

path

The path of the module which caused the error.

FailedModuleUnload #

Bases: TanjunError

Error raised when a module fails to unload.

This may be raised by the module failing to import or by one of its unloaders erroring.

The source error can be accessed at FailedModuleUnload.__cause__.

__cause__ instance-attribute #

__cause__

The root error.

path property #

path

The path of the module which caused the error.

HaltExecution #

Bases: TanjunError

Error raised while looking for a command in-order to end-execution early.

For the most part, this will be raised during checks in-order to prevent other commands from being tried.

InvalidCheck #

Bases: TanjunError, RuntimeError

Error raised as an assertion that a check will never pass in the current environment.

ModuleMissingLoaders #

Bases: RuntimeError, TanjunError

Error raised when a module is missing loaders.

message property #

message

The error message.

path property #

path

The path of the module which is missing loaders.

ModuleMissingUnloaders #

Bases: RuntimeError, TanjunError

Error raised when a module is missing unloaders.

message property #

message

The error message.

path property #

path

The path of the module which is missing unloaders.

ModuleStateConflict #

Bases: ValueError, TanjunError

Error raised when a module cannot be (un)loaded due to a state conflict.

message property #

message

The error message.

path property #

path

The path of the module which caused the error.

NotEnoughArgumentsError #

Bases: ParserError

Error raised by the parser when not enough arguments are found for a parameter.

message instance-attribute #

message = message

String message for this error.

Note

This may be used as a command response message.

parameter instance-attribute #

parameter

Name of the parameter this error was raised for.

__init__ #

__init__(message, parameter)

Initialise a not enough arguments error.

Parameters:

  • message (str) –

    The error message.

  • parameter (str) –

    The parameter this error was raised for.

ParserError #

Bases: TanjunError, ValueError

Base error raised by a parser or parameter during parsing.

Note

Expected errors raised by the parser will subclass this error.

message instance-attribute #

message = message

String message for this error.

Note

This may be used as a command response message.

parameter instance-attribute #

parameter = parameter

Name of the this was raised for.

Note

This will be None if it was raised while parsing the provided message content.

__init__ #

__init__(message, parameter)

Initialise a parser error.

Parameters:

  • message (str) –

    String message for this error.

  • parameter (str | None) –

    Name of the parameter which caused this error, should be None if not applicable.

TanjunError #

Bases: Exception

The base class for all errors raised by Tanjun.

TooManyArgumentsError #

Bases: ParserError

Error raised by the parser when too many arguments are found for a parameter.

message instance-attribute #

message = message

String message for this error.

Note

This may be used as a command response message.

parameter instance-attribute #

parameter

Name of the parameter this error was raised for.

__init__ #

__init__(message, parameter)

Initialise a too many arguments error.

Parameters:

  • message (str) –

    The error message.

  • parameter (str) –

    The parameter this error was raised for.