On Sunday, 5 May 2024 at 17:15:10 UTC, Steven Schveighoffer wrote:
        } catch(Exception e) {
            visualDisplayOfException(e);
            throw e;
        }

Thanks! That's practically the same pattern that I already use for logging: Try-catch near the entry point, show the message, re-throw. My implementation for the message box is now:

    catch (Throwable t) {
        import core.sys.windows.windows;
        const string errText = /* ... parse t ... */
        MessageBoxA(null, errText.ptr, null, MB_ICONERROR);
    }

That solves my problem. Even though I don't pass my game's window as the parent of the message box (first argument, where I pass `null`), the graphical game halts before exiting, shows the error, and users can screenshot both together. That's good.

From your answer, I'll assume: There is no standardized way in the D ecosystem (e.g., by calling a DRuntime function from my usercode) to opt into displaying such a message box for uncaught exceptions. I have to call third-party APIs myself.

Or is there something after all? From reading the 2019 thread [Deactivate windows MessageBox dialog on exception](https://forum.dlang.org/post/tlhjypvsaxzymccfc...@forum.dlang.org), it sounds like we should get an error box when we link with `-subsystem:windows`, and no box otherwise.

-- Simon

Reply via email to