GNOME Bugzilla – Bug 300610
G_TYPE_ERROR (boxed type for GError) missing
Last modified: 2010-04-23 12:45:11 UTC
It would be nice to have a G_TYPE_ERROR covering GError in gboxed.h. I need this, since I use GError in several places as signal parameter. If you think this is a good idea, I can come up with a (simple) patch against CVS.
Created attachment 45446 [details] [review] patch adding G_TYPE_ERROR incl. docs The GStreamer folks would probably also prefer to see this in GLib rather than register their own GstGError type as they do now.
GError is almost a parametrisized type, since you usually have a (set of) allowed error domains and possible error codes around. We have always resisted adding GTypes for the parametrisized container types in GLib. Also, the GType would not be really useful for the most common use of GError, namely passing an GError as an out parameter...
I can see the argument from a theoretical point of view, but I still think it makes sense to add a G_TYPE_ERROR. The type may not be particularly useful for GLib/Gtk itself, but it is useful in order to maintain a consistent API in other GLib-based libraries. I thought the whole point of GError was to have a consistent way of error handling and notification within the 'G platform'. I can't see how passing three callback arguments instead of one (error code, domain and message) provides a consistent API (not to mention that it's clunky). Having 'GstGError *' types details about which cannot be found anywhere in the API reference can probably be remedied by some gtk-doc magic at the end of the day, but it's still ugly. Other libraries just use GError differently than GLib. The costs of the type are extremely low, and there are already at least two libraries who like to have this type, so I don't see much reason not to include it, theoretical reasons aside. Cheers -Tim
Created attachment 48745 [details] [review] gboxed-error.diff This patch implements two boxed types: G_TYPE_ERROR (GError) and G_TYPE_ERROR_POINTER (GError*, typedef'd as GErrorPointer) The latter allows GError to be used in closures and signals as an "out" parameter. I would consider this to be a good addition to GObject; I currently have it implemented in my own code, but being able to propagate errors through callbacks would be a useful ability. Regards, Roger
*** Bug 337092 has been marked as a duplicate of this bug. ***
A boxed type for GError has now been added in GLib 2.25.2, see bug #614541. (Thanks!)
*** This bug has been marked as a duplicate of bug 614541 ***