bot: capture exceptions, try to report on them

it beats crashing, probably
This commit is contained in:
Brian S. Stephan 2017-02-22 22:08:04 -06:00
parent 9c4e0fe782
commit 1bbb64618d
1 changed files with 45 additions and 40 deletions

View File

@ -144,6 +144,7 @@ class DrReactor(irc.client.Reactor):
Also supports regex handlers.
"""
try:
log.debug("EVENT: e[%s] s[%s] t[%s] a[%s]", event.type, event.source,
event.target, event.arguments)
@ -189,6 +190,10 @@ class DrReactor(irc.client.Reactor):
result = handler.callback(connection, event)
if result == "NO MORE":
return
except Exception as ex:
log.error("caught exception!")
log.exception(ex)
connection.privmsg(event.target, str(ex))
def try_recursion(self, connection, event):
"""Scan message for subcommands to execute and use as part of this command.