beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.34k stars 671 forks source link

Callbacks into Toga invoked from .NET do not respect failure modes #2779

Closed rmartin16 closed 2 months ago

rmartin16 commented 2 months ago

Describe the bug

While investigating https://github.com/beeware/toga/issues/2752, I discovered that the RuntimeError being raised because the WebView failed to initialize was swallowed and suppressed. Even running sys.exit(1) did not cause a visible error to be raised.

As such, developers and end-users are not informed of critical runtime errors.

Steps to reproduce

It's probably easiest to just force it; that is, just update winforms_initialization_completed to always raise an Exception and run an app using the WebView.

Expected behavior

Errors detected in such callbacks are reported to users.

Screenshots

No response

Environment

Logs

briefcase.2024_08_19-16_36_06.dev.log

Additional context

No response

freakboy3742 commented 2 months ago

As a workaround, would it make sense to actually write the error message to the console, in addition to raising the RuntimeError and assuming it will be seen/surfaced? I agree this would be less than ideal, but it would be better to output something that indicates there's a problem rather than fail silently when we know there's been a problem.