Module: check_mk
Branch: master
Commit: 799db1b9cde8d032ce891608a9cef11570be7130
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=799db1b9cde8d0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 29 09:51:52 2011 +0200
WATO: better error message if hook fails
---
web/htdocs/wato.py | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index be5b457..36f25da 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3139,8 +3139,17 @@ def collect_hosts(the_thing):
return effective_hosts
def call_hooks(name, *args):
+ n = 0
for hk in hooks.get(name, []):
- hk(*args)
+ n += 1
+ try:
+ hk(*args)
+ except Exception, e:
+ import traceback, StringIO
+ txt = StringIO.StringIO()
+ t, v, tb = sys.exc_info()
+ traceback.print_exception(t, v, tb, None, txt)
+ html.show_error("<h3>" + _("Error executing hook")
+ " %s #%d: %s</h3><pre>%s</pre>" % (name, n, e,
txt.getvalue()))
def call_hook_host_changed(the_thing): # called for file or folder
if "hosts-changed" in hooks: