2012/8/28 alok barsode <[email protected]>:
> Hi,
>
> I am rewriting a dbus based extension in GDBus. Earlier I was using gjs's
> built-in dbus support (libdbus ?)
> I need to raise a dbus exception in my extension. With the built-in dbus
> support I did this:
>
> let err = new DBus.DBusError('net.connman.Agent.Error.Retry', 'retry this
> service');
> throw err;
>
> How do I achieve the same in GDBus?
>
> I am using Ubuntu Percise Pangolin (12.04) and gnome-shell 3.4.1.
With more recent versions of gjs, you could register your GError
domain and throw that. GDBus then would do the rest.
In 3.4, you can use a partial hack:
e = Error(message);
e.name = 'net.connman.Agent.Error.Retry';
throw e;
or you can make your method async, and use the GDBusMethodInvocation directly:
FooAsync: function(parameters, invocation) {
if (ok) {
invocation.return_value(GLib.Variant.new(...));
} else {
invocation.return_dbus_error('org.dbus.foo', 'message');
}
}
Giovanni
_______________________________________________
gnome-shell-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-shell-list