From dec5a89fa614023c3e9fe7b0eff52eb186832f70 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 31 Oct 2008 17:30:34 +0100 Subject: [PATCH] Add log_error decorator for debugging. --- tools/misc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.30.2