Title: Async method calls do not show/print exceptions · Issue #97 · python-sdbus/python-sdbus · GitHub
Open Graph Title: Async method calls do not show/print exceptions · Issue #97 · python-sdbus/python-sdbus
X Title: Async method calls do not show/print exceptions · Issue #97 · python-sdbus/python-sdbus
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(sel...
Open Graph 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(...
X 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_met...
Opengraph URL: https://github.com/python-sdbus/python-sdbus/issues/97
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Async method calls do not show/print exceptions","articleBody":"If the exception occur in a method callback, the exception is not shown:\n\n```python\nimport asyncio\nimport sdbus\n\nclass Test(sdbus.DbusInterfaceCommonAsync, interface_name=\"org.test\"):\n @sdbus.dbus_method_async(result_signature=\"u\")\n async def open(self) -\u003e int:\n print(\"Open call\")\n raise ValueError(\"Nooo\")\n\ntest = Test()\n\nasync def startup() -\u003e None:\n await sdbus.request_default_bus_name_async('org.example.test')\n test.export_to_dbus(\"/\")\n\nloop = asyncio.new_event_loop()\nloop.run_until_complete(startup())\nloop.run_until_complete(asyncio.sleep(10))\nprint(\"Done\")\n```\n\n```console\n$ ./test.py\nOpen call\nDone\n```\n\n```console\n$ gdbus call --session --dest org.example.test --object-path / --method org.test.Open\nError: GDBus.Error:org.freedesktop.DBus.Error.Failed:\n```\n\nIt 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?\n\nAs 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.\n\nIf not, the returned D-Bus error should at least have the `ValueError`'s message included.\n\n#### Setup\n\nsdbus was installed via PIP:\n\n```console\n$ pip freeze |grep sdbus\nsdbus==0.13.0\n```","author":{"url":"https://github.com/arkq","@type":"Person","name":"arkq"},"datePublished":"2025-03-06T10:10:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/97/python-sdbus/issues/97"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0353ed4d-febe-90d6-4af7-57c1a5687dd7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9ACE:B1B60:F6238C:1443DB9:698D774D |
| html-safe-nonce | 1b7633a9080d7884ad1a9d1447eda767b22bf8c49286e5719dd268aade519ca2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUNFOkIxQjYwOkY2MjM4QzoxNDQzREI5OjY5OEQ3NzREIiwidmlzaXRvcl9pZCI6IjUyMTc2MDAyMjc5OTM1NDg2MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4fb1c42b04ec5455a9f8f2b0522055e89b78d7ec1cdf299b9f107df1f5cf94e2 |
| hovercard-subject-tag | issue:2899958003 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-sdbus/python-sdbus/97/issue_layout |
| twitter:image | https://opengraph.githubassets.com/051afe4c82999e96e55dc81862c142379bc7a9f056d7c8c8a28b00b33b5f4ddc/python-sdbus/python-sdbus/issues/97 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/051afe4c82999e96e55dc81862c142379bc7a9f056d7c8c8a28b00b33b5f4ddc/python-sdbus/python-sdbus/issues/97 |
| og:image:alt | 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(... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arkq |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0818105fa276287e9369cfdefa0a0fa7953719791ceff9b94d69623c0a4fe8a |
| turbo-cache-control | no-preview |
| go-import | github.com/python-sdbus/python-sdbus git https://github.com/python-sdbus/python-sdbus.git |
| octolytics-dimension-user_id | 88226657 |
| octolytics-dimension-user_login | python-sdbus |
| octolytics-dimension-repository_id | 311269257 |
| octolytics-dimension-repository_nwo | python-sdbus/python-sdbus |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 311269257 |
| octolytics-dimension-repository_network_root_nwo | python-sdbus/python-sdbus |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 715890fa442134f528fb422ab338c0ad55c7a025 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width