]>
jfr.im git - erebus.git/blob - modules/exception_hook.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # A basic exception hook. Sends exceptions to `[exception_hook] destination` in the config.
4 # This file is released into the public domain; see http://unlicense.org/
8 'author': 'Erebus Team',
9 'license': 'public domain',
10 'compatible': [0], # compatible module API versions
11 'depends': [], # other modules required to work properly?
12 'softdeps': [], # modules which are preferred but not required
17 lib
= modlib
.modlib(__name__
)
18 modstart
= lib
.modstart
24 @lib.hookexception(Exception)
25 def got_exception(bot
, exc
, source
, *args
, **kwargs
):
26 dest
= lib
.parent
.cfg
.get('exception_hook', 'destination')
28 bot
.msg(dest
, '%s exception: %r %r' % (source
, args
, kwargs
))
29 for line
in traceback
.format_exc(limit
=-lib
.parent
.cfg
.getint('exception_hook', 'limit', 5)).split("\n"):
30 bot
.msg(dest
, (' '*4) + line
)