X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fxerxes.git;a=blobdiff_plain;f=tools%2Fmisc.py;h=1259ab7d706284e6abc2164e79d6d90cdbe50143;hp=1edf4725f59ad248f3f28ac11f87819cf54b74d4;hb=dec5a89fa614023c3e9fe7b0eff52eb186832f70;hpb=6441b6d77723178b4456deca4189723205abfada diff --git a/tools/misc.py b/tools/misc.py index 1edf472..1259ab7 100644 --- a/tools/misc.py +++ b/tools/misc.py @@ -14,3 +14,17 @@ def make_iter(value): pass return [value] # vim: set sts=4 sw=4 expandtab: + +""" +Decarator that catches any exception raised by the decorated function, +prints it to stdout and raises it again. +""" +def log_error(func): + def show(*args, **kwargs): + try: + func(*args, **kwargs) + except Exception, e: + import traceback + traceback.print_exc() + raise e + return show