Title: Emit error messages via signals or return them from function calls (optionally) · Issue #51 · MeVisLab/pythonqt · GitHub
Open Graph Title: Emit error messages via signals or return them from function calls (optionally) · Issue #51 · MeVisLab/pythonqt
X Title: Emit error messages via signals or return them from function calls (optionally) · Issue #51 · MeVisLab/pythonqt
Description: Hello! Whenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine does not print to the stderr and instead r...
Open Graph Description: Hello! Whenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine do...
X Description: Hello! Whenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine do...
Opengraph URL: https://github.com/MeVisLab/pythonqt/issues/51
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Emit error messages via signals or return them from function calls (optionally)","articleBody":"Hello!\r\n\r\nWhenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine does not print to the stderr and instead returns a QJSValue containing error message, from which a string could be extracted and emitted via signal. It is very convenient.\r\n\r\nThe way I see it, this is how it could be done:\r\n\r\nWhen error occurs during `PythonQtObjectPtr::evalScript` or `PythonQtObjectPtr::call` calls return QString (wrapped in QVariant) instead of invalid QVariant. `PythonQt::hadError` would then tell whether this variant contains a “normal” string or an error message.\r\n\r\nOr perhaps you could even give errors their own struct, with fields like type, message, etc, and the return value could be tested like this:\r\n\r\n```c++\r\nPythonQtObjectPtr main_module = PythonQt::self()-\u003egetMainModule();\r\nQVariant result = main_module-\u003eevalScript (script);\r\nif (result.canConvert\u003cPythonQtErrorStruct\u003e())\r\n{\r\n PythonQtErrorStruct error = result.value\u003cPythonQtErrorStruct\u003e();\r\n emit errorOccured (error.type, error.message);\r\n}\r\n```\r\n\r\nI am aware that PythonQt lets redirection of stderr, but this is not the same. Plus in some cases user might want to emit error via signal, and in other to simply print it to stderr, so just bluntly redirecting the entire error output seems like a cumbersome solution.","author":{"url":"https://github.com/T-640","@type":"Person","name":"T-640"},"datePublished":"2021-06-27T16:21:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/51/pythonqt/issues/51"}
| 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:43b8a55f-e785-d0ad-d7fc-87ee64f0a656 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B506:1A4AD6:1EB71E3:28AFDB7:6971AA56 |
| html-safe-nonce | 39c0f9a3adef4cc7dbc1dc23aa3dafdc59cb2c1377044d513f915d350709168c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTA2OjFBNEFENjoxRUI3MUUzOjI4QUZEQjc6Njk3MUFBNTYiLCJ2aXNpdG9yX2lkIjoiNjg1MDIzNTMxNDMxMjY4NjE2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3da61b8bb0bffa50162980cf657190e30401531bc57521854d02d05a4c95c89b |
| hovercard-subject-tag | issue:930968604 |
| 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/MeVisLab/pythonqt/51/issue_layout |
| twitter:image | https://opengraph.githubassets.com/99d73a26966871e0b28ff6e09df04ccd206f2a8f9b588d777ee103cb40a80849/MeVisLab/pythonqt/issues/51 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/99d73a26966871e0b28ff6e09df04ccd206f2a8f9b588d777ee103cb40a80849/MeVisLab/pythonqt/issues/51 |
| og:image:alt | Hello! Whenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine do... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | T-640 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b0f2f00499ad3dd2c21ad030a3c403edca54df20ea256f6517c6d8c4fa3a1a4 |
| turbo-cache-control | no-preview |
| go-import | github.com/MeVisLab/pythonqt git https://github.com/MeVisLab/pythonqt.git |
| octolytics-dimension-user_id | 15028021 |
| octolytics-dimension-user_login | MeVisLab |
| octolytics-dimension-repository_id | 193056137 |
| octolytics-dimension-repository_nwo | MeVisLab/pythonqt |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193056137 |
| octolytics-dimension-repository_network_root_nwo | MeVisLab/pythonqt |
| 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 | 979375c570cc30aefe2a734083debe402a612209 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width