In irc3, IRC error messages (ERR) are exposed as events via the irc3.event decorator. You can listen for specific error codes by referencing the corresponding constant in irc3.rfc.
When an error event is triggered, the decorated function receives the bot instance and several keyword arguments parsed from the IRC message, such as srv (the server), me (your nickname), channel, nick, or data (the trailing message text), depending on the specific error's format.
@irc3.event(rfc.ERR_BADCHANNELKEY)
def myevent(bot, srv=None, me=None, channel=None, data=None):
# Handle the error (e.g., 475 - ERR_BADCHANNELKEY)
pass