Draft: RFC: fix _promisify() to reject with Gio.IOError.CANCELLED if a cancellable is passed as an argument and the cancellable is cancelled
When an async function is promisified, has a Gio.Cancellable as an arg, and the cancellable is cancelled, _promisify rejects with the error from the inner async callback function.
If the function is remote, like DBus methods, this triggers a generic DBus.Error.FAILED with a string usually stating "Operation was Cancelled".
But functions such as that one, to quote @ptomato
have no
GError**
out parameter, so they cannot throw GErrors.
This error can be checked by string scraping like, for example-
if (Gio.DBusError.is_remote_error(e) &&
Gio.DBusError.get_remote_error(e).toLowerCase().includes('cancelled')
To my knowledge, there is go generic Gio.DBus.Error.CANCELLED.
Till we come up with a ENUM error that can be checked for specifically, I was thinking of having a _promisifyCancellable() convenience function that would return a Gio.IOError.CANCELLED, if the cancellable is cancelled, instead of the generic error.
Please see the issue in the original Gnome Shell MR 3418!
I am submitting four commits, that all do the same thing, please comment and let me know which ones would work, and which ones would not.