GNOME Bugzilla – Bug 774061
gio: Add g_error_new_default()
Last modified: 2017-10-11 10:42:01 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.
Created attachment 339255 [details] [review] gio: Add g_error_new_default()
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.
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.
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.
I did this in https://github.com/GNOME/libglnx/pull/38 for now instead.
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.