Report development without the need to restart GnuCash

Charles Day cedayiv at gmail.com
Wed May 28 11:37:49 EDT 2008


On Wed, May 28, 2008 at 8:05 AM, Derek Atkins <warlord at mit.edu> wrote:

> "Charles Day" <cedayiv at gmail.com> writes:
>
> > How about the following?  I tested by mangling the cash flow report's
> options
> > generator, and the problem was detected. A backtrace is generated, an
> error is
> > logged to the trace file, and the user sees the usual "An error has
> occurred"
> > in the report window. (Note: The last change corrects a genuine bug,
> which I
> > assume was just a typo of "names" vs. "namer".)
> >
> > I would go ahead and commit this, Derek, but since I'm a reporting API
> noob,
> > perhaps you'd like to take a look first? (Assuming you agree in principle
> with
> > this change.)
> >
> > -Charles
> >
> > $ svn diff
> > Index: src/report/report-system/report.scm
> > ===================================================================
> > --- src/report/report-system/report.scm (revision 17174)
> > +++ src/report/report-system/report.scm (working copy)
> > @@ -253,13 +253,19 @@
> >             (gnc:get-html-style-sheets)))))
> >
> >      (if (procedure? generator)
> > -        (let ((options (generator)))
> > +        (let ((options (gnc:backtrace-if-exception generator)))
> > +          (if (not options)
> > +              (begin
> > +                (gnc:warn "BUG DETECTED: exception raised in "
> > +                          "report options generator procedure named "
> > +                          (procedure-name generator))
> > +                (set! options (gnc:new-options))))
> >            (gnc:register-option options stylesheet)
> >            (gnc:register-option options namer)
> >            options)
> >          (let ((options (gnc:new-options)))
> >             (gnc:register-option options stylesheet)
> > -          (gnc:register-option options names)
> > +          (gnc:register-option options namer)
> >            options))))
> >
> >  ;; A <report> represents an instantiation of a particular report type.
>
> Sure, something like this can work.
>
> I'm surprised to see the "namer" vs. "names" thing..  I wonder why that
> never caused a problem before?
>

Yeah, me too. It must be because every existing report provides an options
generator procedure. That line of code only gets executed if a report
doesn't use one. I thought it looked suspicious though, so to test it I just
defined a report without an options generator and voila... the backtrace
said that "names" was undefined.


>
> -derek
> --
>       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>       Member, MIT Student Information Processing Board  (SIPB)
>       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>       warlord at MIT.EDU                        PGP key available
>


More information about the gnucash-user mailing list