propagating errors w.r.t. quark/domain visibility
- From: Philip Kovacs <kovacsp3 comcast net>
- To: gtk-app-devel-list gnome org
- Subject: propagating errors w.r.t. quark/domain visibility
- Date: Thu, 27 Jul 2006 23:51:42 -0400
Is it considered bad form to g_propagate_error() a custom error back to
a caller,
when the error domain, enum and quark definitions are not visible to
the caller?
Example:
--bar.h-- (an internal module, not seen by the caller)
typedef enum
{
BAR_ERROR_THIS,
BAR_ERROR_THAT
} BarError;
#define BAR_ERROR bar_error_quark ()
GQuark bar_error_quark (void) G_GNUC_INTERNAL;
--foo.h-- (a module with external visibility, called by users)
void do_foo (GError **error);
--foo.c--
#include bar.h
void do_foo (GError **error)
{
GError *local_error = NULL;
... error occurs ...
local_error = g_new_error (BAR_ERROR, BAR_ERROR_THIS, "this error");
g_propagate_error (error, local_error);
return;
}
When do_foo() returns the error to the caller, the user will have in his
hands
an error that occurred "deeply" in the code with a domain and error code
that
cannot be identified, e.g. with g_error_match(). The error can still,
of course,
be reported with g_error (error->message) and it can be cleared/freed or
even
propagated further.
Comments?
Phil
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]