exposing dbus error names on the glib client side
Colin Walters
walters at verbum.org
Tue Jun 21 18:51:23 PDT 2005
Hi,
In the glib client-side bindings, when a service throws an error, we
need a way to figure out what that error is. Right now the API for
ending a call looks like:
gboolean dbus_g_proxy_end_call (DBusGProxy *proxy,
DBusGPendingCall *pending,
GError **error,
GType first_arg_type,
...);
Note that it takes a GError. When the remote end gives us back e.g.
org.freedesktop.HAL.Device.LockFailed error, how can we get that
information? One thought is to have all remote errors turn into
DBUS_G_ERROR/DBUS_G_ERROR_REMOTE, and then you can extract the actual
error name from error->msg. But then how do you get the D-BUS error
message text? In this case we might have a function like:
dbus_g_pending_call_get_error_text. But what do we do for synchronous
calls, like dbus_g_proxy_call and the generated client-side wrappers?
Just for reference, right now what happens is:
void
dbus_set_g_error (GError **gerror,
DBusError *derror)
{
g_return_if_fail (derror != NULL);
g_return_if_fail (dbus_error_is_set (derror));
g_set_error (gerror, DBUS_GERROR,
DBUS_GERROR_FAILED,
_("D-BUS error %s: %s"),
derror->name, derror->message);
}
But this is pretty busted, since you can't reasonably determine what the
error is on the client end (a hack like looking for "D-BUS error" is
bound to fail since the string is translated).
My other thought is to ditch GError and create DBusGError. Somewhat
less pleasant though, since people are going to expect GError.
Anyone have any better suggestions?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050621/c2da247c/attachment.pgp
More information about the dbus
mailing list