On Sunday, 5 May 2024 at 14:55:20 UTC, SimonN wrote:
My application is a graphical game. I close stdout and stderr by passing `-subsystem:windows` to `lld-link` to suppress the extra console window. For a few fatal errors (missing required resources, can't open display, ...), I throw exceptions, log them to logfile, then re-throw them to crash. I can tell Windows users to look in the logfile, but it would be more fitting on Windows to show an error dialog box in addition to the logging.

```d
int realMain(string[] args)
{
   // all your normal code goes here
}

int main(string[] args)
{
    version(Windows) {
        try {
            realMain(args);
        } catch(Exception e) {
            visualDisplayOfException(e);
            throw e;
        }
    } else {
// presumably, non-windows systems shouldn't show a graphical Exception
        // trace?
        realMain(args);
    }
}
```

-Steve

Reply via email to