Module: check_mk
Branch: master
Commit: ec2fd321366864a73c164adf92af350d6544435b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ec2fd321366864…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 11 14:47:31 2014 +0100
#1758 Improved exception hander: Shows details without additional debug request, added
mailto link for error report
In case of exceptions in the Web GUI, the handling should be easier now. We have full
details on the first page without the need to perform an additional request with debug
mode enabled.
Added a context button for reporting the issue via mail to the feedback address.
---
.werks/1758 | 12 ++++++++++++
ChangeLog | 2 ++
web/htdocs/htmllib.py | 29 +++++++++++++++++++++++++++++
web/htdocs/index.py | 7 +------
web/htdocs/lib.py | 7 ++-----
5 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/.werks/1758 b/.werks/1758
new file mode 100644
index 0000000..5b36ab9
--- /dev/null
+++ b/.werks/1758
@@ -0,0 +1,12 @@
+Title: Improved exception hander: Shows details without additional debug request, added
mailto link for error report
+Level: 1
+Component: multisite
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418305269
+
+In case of exceptions in the Web GUI, the handling should be easier now. We have full
details on the first page without the need to perform an additional request with debug
mode enabled.
+
+Added a context button for reporting the issue via mail to the feedback address.
diff --git a/ChangeLog b/ChangeLog
index 7f240fe..77b0a5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
1.2.7i1:
+ Multisite:
+ * 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
1.2.6b1:
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 3d72fff..24bc89a 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -911,6 +911,35 @@ class html:
h += '</div>'
return h
+ def show_exception(self, e):
+ details = \
+ 'Page: ' + self.myfile + '\r\n\r\n' \
+ + 'GET/POST-Variables:\r\n' \
+ + '\r\n'.join([ ' '+n+'='+v for n, v in
sorted(self.vars.items()) ]) + '\r\n' \
+ + '\r\n' \
+ + format_exception()
+
+ mail_body = \
+ "Dear Check_MK Developer team,\r\n\r\n" \
+ + "I hereby send you a report of a crash in the Check_MK Web
GUI:\r\n\r\n" \
+ + details + "\r\n" \
+ + "\r\n\r\nWith best regards,\r\n\r\n"
+
+ self.begin_context_buttons()
+ mailto_url = self.makeuri_contextless([
+ ("subject", "Check_MK GUI Crash Report - " +
defaults.check_mk_version),
+ ("body", mail_body)],
filename="mailto:feedback@check-mk.org")
+ self.context_button(_("Submit Report"), mailto_url, "email")
+ self.end_context_buttons()
+
+ self.show_error("%s: %s" % (_('Internal error'),
self.attrencode(e)))
+
+ self.begin_foldable_container("html", "exc_details", False,
_("Details"))
+ self.write('<div class=log_output>')
+ self.write("<pre>%s</pre>" % details)
+ self.write('</div>')
+ self.end_foldable_container()
+
def show_error(self, msg):
if self.mobile:
self.write('<center>')
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index ca97019..3dd259a 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -317,12 +317,7 @@ def handler(req, fields = None, profiling = True):
html.write(_("Internal error") + ": %s\n" %
html.attrencode(e))
elif not fail_silently:
html.header(_("Internal error"))
- if config.debug:
- html.show_error("%s: %s<pre>%s</pre>" %
- (_('Internal error'), html.attrencode(e),
html.attrencode(format_exception())))
- else:
- url = html.makeuri([("debug", "1")])
- html.show_error("%s: %s (<a
href=\"%s\">%s</a>)" % (_('Internal error') + ':',
html.attrencode(e), url, _('Retry with debug mode')))
+ html.show_exception(e)
html.footer()
response_code = apache.OK
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 9da5812..f36b9f5 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -320,11 +320,8 @@ def format_plugin_output(output, row = None):
return output
def format_exception():
- import traceback, StringIO, sys
- txt = StringIO.StringIO()
- t, v, tb = sys.exc_info()
- traceback.print_exception(t, v, tb, None, txt)
- return txt.getvalue()
+ import traceback
+ return traceback.format_exc()
# Escape/strip unwanted chars from (user provided) strings to
# use them in livestatus queries. Prevent injections of livestatus