In [1]:
from ahh import ext

In [2]:
def zero_division_fn(): # a function
    return 5 / 0 # that obviously won't work

def name_missing_fn():
    return ahh # just to raise an error

In [3]:
try:
    zero_division_fn()
except Exception as e:
    print(e) # very uninformative


division by zero

In [4]:
try:
    zero_division_fn()
except:
    ext.report_err() # much more informative


Nov 10 03:43Z ZeroDivisionError - division by zero on line 2 in <ipython-input-2-55070358f76e>: "return 5 / 0 # that obviously won't work"

In [5]:
try:
    name_missing_fn()
except:
    ext.report_err(save='report_err', comment='Continuing on') # can save to a log and append a comment
print('Continued on')


Nov 10 03:43Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on
Continued on

In [6]:
try:
    name_missing_fn()
except: # just log it without printing to screen
    ext.report_err(save='report_err', comment='Continuing on again without showing', show=False)

In [7]:
with open('report_err.txt', 'r') as f:
    lines = f.read().split('\n')
    for line in lines:
        print(line) # proof


Jun 22 23:37Z NameError - name 'ahh' is not defined on line 5: "return ahh" - Continuing on
Jun 22 23:37Z NameError - name 'ahh' is not defined on line 5: "return ahh" - Continuing on again without showing
Jul 01 16:47Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on
Jul 01 16:47Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on again without showing
Nov 06 02:31Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on
Nov 06 02:31Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on again without showing
Nov 10 03:43Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on
Nov 10 03:43Z NameError - name 'ahh' is not defined on line 5 in <ipython-input-2-55070358f76e>: "return ahh # just to raise an error" - Continuing on again without showing


In [ ]: