Exceptions¶
NioBotException ¶
Bases: Exception
Base exception for NioBot.
Warning
In some rare cases, all of exception
, response
and original
may be None.
All other exceptions raised by this library will subclass this exception, so at least all the below are always available:
Attributes:
Name | Type | Description |
---|---|---|
message |
Optional[str]
|
A simple humanised explanation of the issue, if available. |
response |
Optional[ErrorResponse]
|
The response object from the server, if available. |
exception |
Optional[Union[ErrorResponse, BaseException]]
|
The exception that was raised, if available. |
original |
Union[ErrorResponse, BaseException, None]
|
The original response, or exception if response was not available. |
bottom_of_chain ¶
bottom_of_chain(
other: Optional[Union[Exception, ErrorResponse]] = None
) -> Union[BaseException, ErrorResponse]
Recursively checks the original
attribute of the exception until it reaches the bottom of the chain.
This function finds you the absolute first exception that was raised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Optional[Union[Exception, ErrorResponse]]
|
The other exception to recurse down. If None, defaults to the exception this method is called on. |
None
|
Returns:
Type | Description |
---|---|
Union[BaseException, ErrorResponse]
|
The bottom of the chain exception. |
GenericMatrixError ¶
Bases: NioBotException
Exception for generic matrix errors where a valid response was expected, but got an ErrorResponse instead.
MessageException ¶
LoginException ¶
MediaException ¶
MediaUploadException ¶
MediaDownloadException ¶
MediaCodecWarning ¶
Bases: ResourceWarning
Warning that is dispatched when a media file is not in a supported codec.
You can filter this warning by using warnings.filterwarnings("ignore", category=niobot.MediaCodecWarning)
Often times, matrix clients are web-based, so they're limited to what the browser can display. This is usually:
- h264/vp8/vp9/av1/theora video
- aac/opus/vorbis/mp3/pcm_* audio
- jpg/png/webp/avif/gif images
MetadataDetectionException ¶
Bases: MediaException
Exception raised when metadata detection fails. Most of the time, this is an ffmpeg-related error
CommandError ¶
CommandNotFoundError ¶
CommandPreparationError ¶
CommandDisabledError ¶
CommandArgumentsError ¶
CommandParserError ¶
CheckFailure ¶
Bases: CommandPreparationError
Exception raised when a generic check call fails.
You should prefer one of the subclass errors over this generic one, or a custom subclass.
CheckFailure
is often raised by the built-in checker when a check returns a falsy value without raising an error.
NotOwner ¶
InsufficientPower ¶
Bases: CheckFailure
Exception raised when the command invoker does not have enough power to run the command.