catching Errors in OS callbacks how to print stack trace?
NaN
divide at by.zero
Mon Feb 24 13:42:01 UTC 2020
Normally a failed assert gives the file, line number and a stack
trace, but I hit one today that just prints..
assertion failure
Im sure it is because it's in the WindowProc callback from the
OS. As the callback is nothrow you need to catch and handle
anything there, you have to catch all throwables or else it just
hangs when you hit an assert. But how do I get it to print the
full file, line, and stack trace?
Here's my window proc...
extern(Windows)
LRESULT WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
lparam) nothrow
{
try
{
auto window = cast(Window) (cast(void*)
GetWindowLongPtr(hwnd, 0));
if (window is null)
return DefWindowProcA(hwnd, msg, wparam, lparam);
else
return window.windowProc(msg, wparam, lparam);
}
catch (Throwable e)
{
try { writeln(e.msg); }
catch(Exception what) {}
PostQuitMessage(0);
return 0;
}
}
More information about the Digitalmars-d-learn
mailing list