Skip to content

Exceptions

sharkbound edited this page Sep 3, 2022 · 10 revisions

Table of contents:

InvalidArgumentsError

Used to trigger an automatic error message showing the reason for the error (passed as reason= in InvalidArgumentsError(reason='<message to chat here>'))

example:

from twitchbot import Command, Message, InvalidArgumentsError


@Command(name='error')
async def cmd_test(msg: Message):
    raise InvalidArgumentsError(reason='<message to chat here>',
                                cmd=cmd_test)  # cmd= is not required, but is used to signal which command raised the error

The above code will print this error message in twitch chat:

<message to chat here> - syntax: "" - do "?help error" for more details
Clone this wiki locally