[Reports] Improve error message when html generation fails.

Per Chris Lam's comment 7 on https://bugs.gnucash.org/show_bug.cgi?id=799148.
This commit is contained in:
John Ralls 2024-05-28 13:08:57 -07:00
parent 5c716cc95c
commit 8106ffb84b

View File

@ -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;
}
}