X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=tools%2Fmisc.py;h=1259ab7d706284e6abc2164e79d6d90cdbe50143;hb=dec5a89fa614023c3e9fe7b0eff52eb186832f70;hp=110c370a74500672c1749dbaf4bb4b9f7c115ae8;hpb=30a3414a97f6bbcae73a936f658b639296fcdf98;p=matthijs%2Fprojects%2Fxerxes.git diff --git a/tools/misc.py b/tools/misc.py index 110c370..1259ab7 100644 --- a/tools/misc.py +++ b/tools/misc.py @@ -13,3 +13,18 @@ def make_iter(value): except TypeError: 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