projects
/
matthijs
/
projects
/
xerxes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6441b6d
)
Add log_error decorator for debugging.
author
Matthijs Kooijman
<matthijs@stdin.nl>
Fri, 31 Oct 2008 16:30:34 +0000
(17:30 +0100)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Fri, 31 Oct 2008 16:30:34 +0000
(17:30 +0100)
tools/misc.py
patch
|
blob
|
history
diff --git
a/tools/misc.py
b/tools/misc.py
index 1edf4725f59ad248f3f28ac11f87819cf54b74d4..1259ab7d706284e6abc2164e79d6d90cdbe50143 100644
(file)
--- 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