GJS throwing DBUS errors from asynchronous methods



Hello.

I'm working with GJS and I'm having some troubles managing error
conditions from asynchronous callbacks in D-Bus. The problem appears
whenever I need to do something in an asynchronous context and finish
throwing a DBUS error as a result of the D-Bus callback management. To
help to clarify the problem, imagine the next scenario when we have an
object exposing an asynchronous DBUS method, whenever this method gets
called whe need to open a windows dialog to get some data imput from
the user, after the user pulses accept we process that data in the
button handler function and if there was some problem we need to throw
a DBus exception. Next you are the pseudo code program describing the
problem:

/* DBus exposed method */
RequestInputAsync: function(params, callback) {

        this._inputDialog = new RequestInputDialog(params);

        /* Next is the callback we will use to process the user data
once the user pulse Done button */
        /* Note that we provide the DBus callback in order to reply
the caller of the DBus method  */
        this._inputDialog.connect('done', Lang.bind(this,
this._onDialogDone, callback));
        this._inputDialog.open();
},

/* Next is the callback we will use to process the user data once the
user pulse OK button */
_onDialogDone(userdata, callback) {
         this._inputDialog.close();
        if (isEverythingIsOK(userdata))
            callback();
        else
             /* FIXE: This exception is not being thrown into the DBus
callback context */
            throw new DBus.DBusError('example.error.Canceled', 'Bad
input data');
}

How could I manage this use case throwing the Dbus excepction in the
proper context?. I tried even providing the exception in the callback
parameter but it didn't work.

Regards.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]