Silent error when using hashmap

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 26 17:34:28 PDT 2017


FatalCatharsis wrote:

> On Thursday, 27 July 2017 at 00:12:20 UTC, ketmar wrote:
>> 'cause windows' event handler called from darkes depths of windows code, 
>> and D just can't make sense of the stack to unwind it properly and to 
>> show you error message and stack trace. never ever rely on getting 
>> proper stack traces for exceptions thrown in windows callbacks: it *may* 
>> work sometimes, but it is not guaranteed.
>
> Is there a way to get it to not fail so hard so that prints that occur 
> before and after the failure aren't lost? The "begin" and "end" in the 
> main don't even get output when the failure happens.

wrap the whole event handler function in `try/catch` block, and print it 
there. after all, this is what Dmain does, and so can you. having *full* 
stack trace has no sense there anyway, as you know for sure that event 
handler is called by windows, not by you (and usually from your event loop 
anyway, so detailed stack trace has little useful info).


More information about the Digitalmars-d mailing list