[window-report] show backtrace when report crashes

* exposes a SCM string last-captured-error containing last backtrace
* when rendering report-crash window, include it
This commit is contained in:
Christopher Lam 2019-09-22 18:46:12 +08:00
parent a259ba4a3e
commit 9832fa397a
2 changed files with 15 additions and 6 deletions

View File

@ -274,10 +274,16 @@ gnc_html_report_stream_cb (const char *location, char ** data, int *len)
if (!ok)
{
SCM captured = scm_c_eval_string ("gnc:last-captured-error");
gchar *captured_str = gnc_scm_to_utf8_string(captured);
*data = g_strdup_printf ("<html><body><h3>%s</h3>"
"<p>%s</p></body></html>",
"<p>%s</p><pre>%s</pre></body></html>",
_("Report error"),
_("An error occurred while running the report."));
_("An error occurred while running the report."),
captured_str);
g_free (captured_str);
/* Make sure the progress bar is finished, which will also
make the GUI sensitive again. Easier to do this via guile

View File

@ -63,14 +63,17 @@
(define (gnc:backtrace-if-exception proc . args)
(let* ((apply-result (gnc:apply-with-error-handling proc args))
(result (car apply-result))
(error (cadr apply-result)))
(captured-error (cadr apply-result)))
(cond
(error
(display error (current-error-port))
(captured-error
(display captured-error (current-error-port))
(set! gnc:last-captured-error (gnc:html-string-sanitize captured-error))
(when (defined? 'gnc:warn)
(gnc:warn error)))
(gnc:warn captured-error)))
(else result))))
(define-public gnc:last-captured-error "")
;; This database can be used to store and retrieve translatable
;; strings. Strings that are returned by the lookup function are
;; translated with gettext.