From 377d2145faee0f650cc1b887e85aa28b1775b6ef Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 24 Dec 2010 13:16:09 -0600 Subject: [PATCH] catch all exceptions around self.do, and log to console as much as i find this uncouth, it is handy, and also it seems that the megahal brain gets corrupted/unusable when an exception isn't caught and the bot dies. this should cover most of the cases --- Module.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Module.py b/Module.py index 2318992..a8c2bcf 100644 --- a/Module.py +++ b/Module.py @@ -158,7 +158,10 @@ class Module(object): elif strip_bot_name_from_input: what = addressed_re.sub('', what) - self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + try: + self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + except Exception as e: + print('EXCEPTION: ' + str(e)) def on_privmsg(self, connection, event): """ @@ -190,7 +193,10 @@ class Module(object): if internal_only and replypath is not None: return - self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + try: + self.do(connection, event, nick, userhost, replypath, what, admin_unlocked) + except Exception as e: + print('EXCEPTION: ' + str(e)) def reload(self): """Reload this module's code and then create a new object of it, removing the old."""