Open pespin opened 7 years ago
For reference, I'm finally doing something like this now. Still not checked it's correct as I cannot reproduce the exception:
try:
method()
except Exception as e:
if isinstance(e, GLib.Error) and err_str in e.domain:
return
raise e
I ended up with:
from gi.repository.GLib import GError
...
try:
thing()
except GError as e:
if 'dbus.Error.Name' in str(e.args):
print('Deal with this error')
else:
raise e
still learning python, so not sure if that's right, but it is handling the exception.
This is probably useful as reference: https://pygobject.readthedocs.io/en/latest/guide/api/error_handling.html
In Dbus methods can return errors instead of returning expected value. I could not find simple example or good documentation on how to handle them. A simple example showing how to handle common errors should be provided, as well as adding a paragraph in the documentation/tutorial.
For instance, from ofono https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/doc/network-api.txt:
And I got this stack trace today:
For now I'll try to do something like this, but it's still not clear to me whether this is correct or not: