gEDA-dev: libgeda error reporting

Peter TB Brett peter at peter-b.co.uk
Tue Jul 3 02:24:12 EDT 2007


On Monday 02 July 2007 21:25:23 Ivan Stankovic wrote:
> On Mon, Jul 02, 2007 at 06:51:53PM +0100, Peter TB Brett wrote:
> > On Monday 02 July 2007 17:35:12 Ales Hvezda wrote:
> > > Originally intended, but should be removed or fixed now.
> > > libgeda calls should return error status and if necessary
> > > write something to the log.
> >
> > The GError mechanism would be suitable, I think.
>
> Peter, I looked at GError and it seems to require
> adding a GError ** argument to every function that can
> fail, which is pretty ugly. Overall, I find GError
> clumsy.
>
> What I would prefer is the simple errno-like behaviour:
>
> 1. call a function
> 2. check the return value
> 3. if it's NULL or < 0 or whatever convention we agree on,
>    print the error string
>
> The main problem with this is how to make error codes
> and strings thread safe. Thoughts?

(1) Don't forget there's quite a few places where we want to print warnings
    too.  (I imagine that a revamp of the log mechanism would help with that).

(2) Do we want to internationalize libgeda warnings/errors with gettext?  I'm
    quite keen on the idea.

(3) You're going to have to add an extra return value to the vast majority of
    functions _anyway_ if you want threadsafe error numbers (because static
    error number variables just _aren't_ no matter which way you fiddle them). 

My rationale for leaning towards GError (even though it might appear clumsy) 
is that it does everything we want, the way it works is crystal clear, 
someone else is going to maintain it, and we're linking it in already.

Of course, working code is worth a thousand words, so by all means do what you 
think best.

                      Peter

-- 
Fisher Society committee                    http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
CU Spaceflight                              http://tinyurl.com/ognu2

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com                                  peter-b.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20070703/742ddc3f/attachment.pgp 


More information about the geda-dev mailing list