Re: Some comments about GVFS

On 5/3/07, Havoc Pennington <hp redhat com> wrote:

Yeah, I think this keeps the Cairo model from being "fully general" - it
only works for some types of operations or objects. Another thing about
the Cairo model is that it's either weird or possibly broken if an
object is used by multiple threads, which could arise in the current
gvfs presumably.

For those reasons I don't agree at all with Benjamin that GError is the
"old" approach, I think it is still the right approach *for errors that
should generally be handled or recovered from in some way*.

I think the cairo style is the best way for recoverable errors that
are fatal for the affected object. In that case you want to put the
object into an error state and ignore further functions called on the
To bring up some examples: GdkPixbufLoaders, GKeyFile, GBookmarkFile, GMarkup.
All of those have a lot of functions (not all of them) that are fatal
to the object and both the API and the code using it would look a lot
nicer if there was one argument less.
It may be interesting for some objects to have a function to recover
from errors.

It's very very important IMO to distinguish the three types of errors
(programming, recoverable, and unavoidable-and-ignorable) when designing
any API in this area.

I'm not sure there are "unavoidable-and-ignorable" errors. At least
I'm not very impressed by the error reporting of Gtk when X has
problems. (That one's probably mostly Xlib's fault though). I agree
with you that there are programming errors and recoverable errors, but
not ignorable errors. Even cairo drawing errors should be somehow
handled, and even if it's just printing to stdout. But almost all of
those errors indicate a problem in your code (like cairo_scale (cr,
0.0, x)).

The reason for allowing the programmer to check errors whenever he
wants is to make programs of lazy people easier. We all know that good
programs check errno after every call into libc, but most of us are
lazy. And lazy people don't remember later that they passed NULL to
g_key_file_get_double(). Nor do people that have to fix bugs.
And to say it once again: It's nice that the object carries the object
around with it. That way I don't have to carry the Error around myself
all the time as an extra argument.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]