[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-dev: libgeda error reporting
to quote the api docs....
First and foremost: /GError
<http://www.gtk.org/api/2.6/glib/glib-Error-Reporting.html#GError>
should only be used to report recoverable runtime errors, never to
report programming errors./ If the programmer has screwed up, then you
should use g_warning()
<http://www.gtk.org/api/2.6/glib/glib-Message-Logging.html#g-warning>,
g_return_if_fail()
<http://www.gtk.org/api/2.6/glib/glib-Warnings-and-Assertions.html#g-return-if-fail>,
g_assert()
<http://www.gtk.org/api/2.6/glib/glib-Warnings-and-Assertions.html#g-assert>,
g_error()
<http://www.gtk.org/api/2.6/glib/glib-Message-Logging.html#g-error>, or
some similar facility. (Incidentally, remember that the g_error()
<http://www.gtk.org/api/2.6/glib/glib-Message-Logging.html#g-error>
function should /only/ be used for programming errors, it should not be
used to print any error reportable via GError
<http://www.gtk.org/api/2.6/glib/glib-Error-Reporting.html#GError>.)
then to point out...
g_error and g_warning are part of GLog which gtk itself uses.
So first determine what task you are trying to accomplish then use the
best tool.
Steve M.
Peter TB Brett wrote:
> 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
>
>
> ------------------------------------------------------------------------
>
>
>
> _______________________________________________
> geda-dev mailing list
> geda-dev@xxxxxxxxxxxxxx
> http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev
>
_______________________________________________
geda-dev mailing list
geda-dev@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev