Hello gnucash team,

I think I have worked out a way to trap reports without losing the error
information.
I  will include the whole run-report routine from report.scm because it
has had some patches applied and probably probably wouldn't patch well
against CVS.

Hopefully somebody can incorporate it without too much trouble.

Cheers.

--

 Matt Martin
[EMAIL PROTECTED]

600 West Grove Parkway  #1042
Tempe, AZ, 85283

(480) 775 2660

----- Code Below -----------

(define (gnc:run-report report-name)
  ;; Return a string consisting of the contents of the report.

  (define (display-report-list-item item port)
    (cond
     ((string? item) (display item port))
     ((null? item) #t)
     ((list? item) (map (lambda (item) (display-report-list-item item
port))
                        item))
     (else (gnc:warn "gnc:run-report - " item " is the wrong type."))))

  (let ((report (hash-ref *gnc:_report-info_* report-name)))
    (if (not report)
        #f
        (let* ((options (gnc:report-options report))
         (rendering-thunk (gnc:report-rendering-thunk report))
               (lines
  (catch #t (lambda () (rendering-thunk options))
         (lambda (key . args)
    (let* ((astack (make-stack #t gnc:report-rendering-thunk 4)))
      (display "Report Error in procedure: ")
      (apply display-error  #f (current-error-port) args )
      #f
      )))
  ))
          (if (not lines)
       #f
              (call-with-output-string
               (lambda (port)
                 (for-each
                  (lambda (item) (display-report-list-item item port))
                  lines))))))
       ))


(define (gnc:run-report report-name)
  ;; Return a string consisting of the contents of the report.

  (define (display-report-list-item item port)
    (cond
     ((string? item) (display item port))
     ((null? item) #t)
     ((list? item) (map (lambda (item) (display-report-list-item item port))
                        item))
     (else (gnc:warn "gnc:run-report - " item " is the wrong type."))))

  (let ((report (hash-ref *gnc:_report-info_* report-name)))
    (if (not report)
        #f
        (let* ((options (gnc:report-options report))
                (rendering-thunk (gnc:report-rendering-thunk report))
               (lines 
                (catch #t (lambda () (rendering-thunk options))
                       (lambda (key . args) 
                         (let* ((astack (make-stack #t gnc:report-rendering-thunk 4)))
                           (display "Report Error in procedure: ")
                           (apply display-error  #f (current-error-port) args )
                           #f
                           )))
                ))
          (if (not lines)
              #f
              (call-with-output-string
               (lambda (port)
                 (for-each
                  (lambda (item) (display-report-list-item item port))
                  lines))))))
       ))

--
Gnucash Developer's List 
To unsubscribe send empty email to: [EMAIL PROTECTED]

Reply via email to