Errors
matrix.py uses a structured exception hierarchy so you can catch errors at exactly the right level of specificity. All library exceptions inherit from MatrixError.
from matrix.errors import CommandNotFoundError, CooldownError
@bot.error
async def on_error(ctx, error):
if isinstance(error, CooldownError):
await ctx.reply(f"Slow down! Retry in {error.retry:.1f}s.")
elif isinstance(error, CommandNotFoundError):
await ctx.reply("Unknown command.")
else:
raise error
matrix.errors
Callback
module-attribute
Callback = Callable[..., Coroutine[Any, Any, Any]]
MatrixError
Bases: Exception
RoomNotFoundError
Bases: MatrixError
RegistryError
Bases: MatrixError
AlreadyRegisteredError
AlreadyRegisteredError(entry)
Bases: RegistryError
Source code in matrix/errors.py
25 26 27 28 | |
CommandError
Bases: MatrixError
CommandNotFoundError
CommandNotFoundError(cmd)
Bases: CommandError
Source code in matrix/errors.py
36 37 | |
CommandAlreadyRegisteredError
CommandAlreadyRegisteredError(cmd)
Bases: CommandError
Source code in matrix/errors.py
41 42 | |
MissingArgumentError
MissingArgumentError(param)
Bases: CommandError
Source code in matrix/errors.py
46 47 | |
CheckError
CheckError(cmd, check)
Bases: CommandError
Source code in matrix/errors.py
51 52 | |
GroupError
Bases: CommandError
ConfigError
ConfigError(error)
Bases: MatrixError
Source code in matrix/errors.py
60 61 | |
CooldownError
CooldownError(cmd, check, retry)
Bases: CheckError
Source code in matrix/errors.py
65 66 67 | |
retry
instance-attribute
retry = retry