From c0a38d34793e6f5309ebed7254633be19ca74fc9 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 7 Jun 2025 17:59:40 +0800 Subject: [PATCH] [reports] more robust error handling if target report doesn't exist addendum last commit --- gnucash/report/gnc-report.cpp | 4 +++- gnucash/report/html-utilities.scm | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gnucash/report/gnc-report.cpp b/gnucash/report/gnc-report.cpp index 0a3974d3a7..32f94a6e1a 100644 --- a/gnucash/report/gnc-report.cpp +++ b/gnucash/report/gnc-report.cpp @@ -273,7 +273,9 @@ gnc_report_id_string_to_report_id (const char *id_string) if (end_ptr == anchor_str || *end_ptr != '\0') return -1; const SCM get_linked = scm_c_eval_string ("gnc:report-get-linked-report"); - return scm_to_uint (scm_call_2 (get_linked, scm_from_uint (rpt_id), scm_from_uint (anchor_id))); + + auto id = scm_call_2 (get_linked, scm_from_uint (rpt_id), scm_from_uint (anchor_id)); + return scm_is_number (id) ? scm_to_int (id) : -1; } gboolean diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm index 847da82abf..579dfd2e85 100644 --- a/gnucash/report/html-utilities.scm +++ b/gnucash/report/html-utilities.scm @@ -176,13 +176,13 @@ ((reportname src-options optionlist) (let* ((options (gnc:make-report-options reportname)) (db (gnc:optiondb options))) - (gnc:options-copy-values src-options options) - (for-each - (lambda (l) - (gnc-set-option db (car l) (cadr l) (caddr l))) - optionlist) - (gnc:make-report reportname options))) - (_ (gnc:error "invalid id " id)))) + (cond + (options + (gnc:options-copy-values src-options options) + (for-each (lambda (l) (apply gnc-set-option db l)) optionlist) + (gnc:make-report reportname options)) + (else (gnc:error "cannot find temport template " reportname) #f)))) + (_ (gnc:error "invalid src-id " src-id " id " id) #f))) ;; returns the account name as html-text and anchor to the register. (define (gnc:html-account-anchor acct)