X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fxerxes.git;a=blobdiff_plain;f=tools%2Fmisc.py;h=ba84f05e87141c0be4a9e2efd14bdf1d906dbc1d;hp=1edf4725f59ad248f3f28ac11f87819cf54b74d4;hb=4bd2ee34c818b499888d3f0bb52ffbf1eb58580b;hpb=f1833394374f434a61ab1ab9a551f2bded207182 diff --git a/tools/misc.py b/tools/misc.py index 1edf472..ba84f05 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: + return func(*args, **kwargs) + except Exception, e: + import traceback + traceback.print_exc() + raise e + return show