Example #1
0
 def setUp(self):
     en.enable(callback=exc_handler_ret)
Example #2
0
 def setUp(self):
     en.enable(callback=exc_handler_ret, both=True)
It turns out that both cgitb.handler and exception_notifier.mail_exception does
not terminate the program after handling exception. This is a violation of
default Python behavior.

Since nov. 30, 2013
"""

import sys
sys.path.insert(0, '..')

import exception_notifier as en
import cgitb

cgitb.enable()


def f():
    1 / 0


if __name__ == '__main__':
    en.enable()
    f()
    en.disable()

    try:
        f()
    except:
        cgitb.handler()
    print("After an exception is caught, should this show up?")
Example #4
0
 def setUp(self):
     en.enable()
"""
Script for manual tests.

Since nov. 28, 2013
"""

import sys
sys.path.insert(0, '..')

import exception_notifier as en


def div(x, y):
    return x / y


def cb():
    return 'E'

g = en.mail_exception()(div)

if __name__ == '__main__':
    # test decorator
    g(1, 0)

    # test enable
    en.enable(callback=cb, both=True)
    # XXX: Cannot get return value of callback in exception hook.
    print(div(1, 0))
    en.disable()