[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] "librifying" libarch
From: |
Colin Walters |
Subject: |
Re: [Gnu-arch-users] "librifying" libarch |
Date: |
Mon, 20 Oct 2003 15:36:43 -0400 |
On Mon, 2003-10-20 at 12:55, Tom Lord wrote:
> Leave the invariants alone, but otherwise, if any of the -utils can
> exit (by panic, exit, or a safe_* call), change them to return an
> error value and update callers.
GLib has a nice thing called GError that is a good way to write things
like this. The GError structure itself is actually quite simple:
struct _GError
{
GQuark domain;
gint code;
gchar *message;
};
domain and code just give a programmatic way to know which layer raised
an error; in OO languages this would be equivalent to the class of the
exception.
The main thing about GError is that it's also a *protocol* that has to
be followed inside libraries and by clients using those libraries. It
provides a clean way to know when an error occurred, and also to ignore
errors if you like.
I suggest that if someone takes on the task of switching libarch to
propagating errors, they design an error framework along these lines.
Here's the documentation for GError:
http://developer.gnome.org/doc/API/2.0/glib/glib-Error-Reporting.html
signature.asc
Description: This is a digitally signed message part