Re: How to raise a dbus exceptions in GDBus
- From: Giovanni Campagna <scampa giovanni gmail com>
- To: alok barsode <alokbarsode gmail com>
- Cc: gnome-shell-list gnome org
- Subject: Re: How to raise a dbus exceptions in GDBus
- Date: Tue, 28 Aug 2012 22:10:08 +0200
2012/8/28 alok barsode <alokbarsode gmail com>:
> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]