After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774061 - gio: Add g_error_new_default()
gio: Add g_error_new_default()
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-11-07 14:44 UTC by Colin Walters
Modified: 2017-10-11 10:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: Add g_error_new_default() (8.01 KB, patch)
2016-11-07 14:44 UTC, Colin Walters
none Details | Review

Description Colin Walters 2016-11-07 14:44:50 UTC
Particularly in newer codebases that use `attribute((cleanup))` and
`return FALSE` style extensively, it's really convenient to have a
variant of `g_set_error()` that always does a `return FALSE` and uses
`G_IO_ERROR_FAILED` for cases where we want to set an error that
doesn't need its own domain/code.
Comment 1 Colin Walters 2016-11-07 14:44:58 UTC
Created attachment 339255 [details] [review]
gio: Add g_error_new_default()
Comment 2 Matthias Clasen 2016-11-07 14:49:36 UTC
I don't really like this codification of G_IO_ERROR_FAILED as the official 'i'm to lazy to set up my error codes' error code.

If we want to support that, we should probably have dedicated error code for that.
Comment 3 Colin Walters 2016-11-07 16:20:51 UTC
I don't see the value in every library and application having its own error domain.  It's just not worth the boilerplate if no one is going to "catch" the error.

`git grep G_IO_ERROR_FAILED` across various codebases and you can see how widespread this is now.
Comment 4 Matthias Clasen 2016-11-07 16:22:41 UTC
I know it is widespread, but it is still not right. G_IO_ERROR_FAILED (used to) have a meaning: "io failed for some unknown reason".

We can introduce generic codes in GError, no need for every library to do it.
Comment 5 Colin Walters 2017-03-21 15:41:38 UTC
I did this in https://github.com/GNOME/libglnx/pull/38 for now instead.
Comment 6 Philip Withnall 2017-10-11 10:42:01 UTC
I agree with Matthias: I don’t want to ratify G_IO_ERROR_FAILED as the lazy man’s error code. There is obviously a problem with people defaulting to using it for everything, but I think that should be fixed by making it easier to define custom error domains.

→ Closing.