From 8106ffb84bfe20583c18b3ecebc69623ebeed157 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 28 May 2024 13:08:57 -0700 Subject: [PATCH] [Reports] Improve error message when html generation fails. Per Chris Lam's comment 7 on https://bugs.gnucash.org/show_bug.cgi?id=799148. --- gnucash/report/gnc-report.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gnucash/report/gnc-report.cpp b/gnucash/report/gnc-report.cpp index 39742f3f67c..8146b792526 100644 --- a/gnucash/report/gnc-report.cpp +++ b/gnucash/report/gnc-report.cpp @@ -230,10 +230,17 @@ gnc_run_report_with_error_handling (gint report_id, gchar ** data, gchar **errms } else { - *errmsg = scm_is_string (captured_error) ? gnc_scm_to_utf8_string (captured_error) : + constexpr const char* with_err = "Report %s failed to generate html: %s"; + constexpr const char* without_err = "Report %s Failed to generate html but didn't raise a Scheme exception."; + auto scm_err = scm_is_string (captured_error) ? gnc_scm_to_utf8_string (captured_error) : g_strdup (""); + + if (scm_err && *scm_err) + *errmsg = g_strdup_printf (with_err, gnc_report_name (report), scm_err); + else + *errmsg = g_strdup_printf (without_err, gnc_report_name (report)); + *data = nullptr; - PWARN ("Error in report: %s", *errmsg); return FALSE; } }