-
-
Notifications
You must be signed in to change notification settings - Fork 25
Description
If the exception occur in a method callback, the exception is not shown:
import asyncio
import sdbus
class Test(sdbus.DbusInterfaceCommonAsync, interface_name="org.test"):
@sdbus.dbus_method_async(result_signature="u")
async def open(self) -> int:
print("Open call")
raise ValueError("Nooo")
test = Test()
async def startup() -> None:
await sdbus.request_default_bus_name_async('org.example.test')
test.export_to_dbus("/")
loop = asyncio.new_event_loop()
loop.run_until_complete(startup())
loop.run_until_complete(asyncio.sleep(10))
print("Done")$ ./test.py
Open call
Done$ gdbus call --session --dest org.example.test --object-path / --method org.test.Open
Error: GDBus.Error:org.freedesktop.DBus.Error.Failed:It is visible on the client side that something was wrong DBus.Error.Failed, but it's hard to tell what was wrong. It would be nice to have a traceback printed in case of an exception in a D-Bus API handler (method or property). However, I'm not sure whether that is intentional or a bug?
As a workaround I can wrap method/property code in a try/except block, but I think that it would be nicer to have a traceback in case of non-DBus exception. If someone would like to return an error from a method/property, a dedicated DBus exception should be used. What do you think? Otherwise it's really, reaaaaalllyyy hard to debug issues (e.g. a simple typo) in a program based on sdbus library.
If not, the returned D-Bus error should at least have the ValueError's message included.
Setup
sdbus was installed via PIP:
$ pip freeze |grep sdbus
sdbus==0.13.0