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 684969 - Use g_dataset_id_set_data() to store remote errors in GError
Use g_dataset_id_set_data() to store remote errors in GError
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-09-27 14:55 UTC by Stef Walter
Modified: 2018-05-24 14:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: Don't prefix gdbus errors (10.91 KB, patch)
2012-09-27 16:20 UTC, Stef Walter
none Details | Review
GError: Add concept of attaching an identifier to an error (5.05 KB, patch)
2012-09-28 17:12 UTC, Stef Walter
none Details | Review
gdbus: Use g_error_set_identifier() to tag DBus errors (14.97 KB, patch)
2012-09-28 17:12 UTC, Stef Walter
none Details | Review

Description Stef Walter 2012-09-27 14:55:41 UTC
Currently GDBus prepends remote DBus error strings in the @message parameter of GError. This changed the semantics of the @message parameter from a human-readable string to a sorta structured string. It requires constant use of g_dbus_error_strip_remote_error() in code, which everybody forgets to do.

We can just use g_dataset_id_set_data_full() with a unique quark and a pointer to the GError struct to store a the remote error string. g_error_free() would need to call g_dataset_destroy() with a pointer to itself.

g_dbus_error_get_remote_error() would use g_dataset_id_get_data(), as would g_dbus_error_is_remote_error().

g_dbus_error_strip_remote_error() would become a deprecated no op.

Will try to cook up a patch for this.
Comment 1 David Zeuthen (not reading bugmail) 2012-09-27 15:29:04 UTC
Sounds good to me - should also add

 const gchar *g_dbus_error_peek_remote_error (GError *error);

for C convenience (where the pointer is only valid until @error is cleared).
Comment 2 Allison Karlitskaya (desrt) 2012-09-27 15:31:15 UTC
Using datasets in this way to 'expand unexpandable structures' makes me uncomfortable...
Comment 3 Allison Karlitskaya (desrt) 2012-09-27 15:32:01 UTC
Plus -- how would you propose this works in cases like g_prefix_error()?
Comment 4 David Zeuthen (not reading bugmail) 2012-09-27 15:48:02 UTC
(In reply to comment #3)
> Plus -- how would you propose this works in cases like g_prefix_error()?

I'd except functions modifying a GError in-place keeps the associated data. I'd also except g_error_copy() to do a deep copy of the associated data.
Comment 5 Stef Walter 2012-09-27 15:58:26 UTC
(In reply to comment #3)
> Plus -- how would you propose this works in cases like g_prefix_error()?

This new way works with g_prefix_error() really well. It's the previous "GDBus.Error:" g_dbus_error_strip_remote_error() stuff that didn't work with g_prefix_error().

The new solution also works with g_propagate_error() and g_propagate_prefixed_error().

(In reply to comment #2)
> Using datasets in this way to 'expand unexpandable structures' makes me
> uncomfortable...

Hmmm. Why? That's what it's for. See the first paragraph of the description of the Datasets page. Well do an 's/external//' on the paragraph. :)

(In reply to comment #4)
> I'd
> also except g_error_copy() to do a deep copy of the associated data.

Well I haven't made that work in the patch I worked on so far. Currently the only modification to GError was adding a g_dataset_destroy(). But in order to accomplish the above, there would need to be further logic in GError.
Comment 6 Stef Walter 2012-09-27 16:20:24 UTC
Created attachment 225268 [details] [review]
WIP: Don't prefix gdbus errors
Comment 7 Stef Walter 2012-09-28 17:12:15 UTC
Created attachment 225347 [details] [review]
GError: Add concept of attaching an identifier to an error

This will be used by GDBus to tag GError structures with its
DBus error names, rather than changing the semantics of the
human readable message strings.
Comment 8 Stef Walter 2012-09-28 17:12:50 UTC
Created attachment 225348 [details] [review]
gdbus: Use g_error_set_identifier() to tag DBus errors

Tag DBus errors with DBus error names using the new identifiers
on GError structures rather than changing the semantics of the
human readable message strings.
Comment 9 Stef Walter 2012-10-02 16:40:22 UTC
FWIW, these mangled error->message strings are showing up everywhere: https://bugzilla.redhat.com/show_bug.cgi?id=862333
Comment 10 GNOME Infrastructure Team 2018-05-24 14:40:44 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/610.