Silent error when using hashmap

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 26 18:21:40 PDT 2017


On 7/26/17 8:51 PM, FatalCatharsis wrote:
> On Thursday, 27 July 2017 at 00:48:48 UTC, ketmar wrote:
>> FatalCatharsis wrote:
>>
>>> On Thursday, 27 July 2017 at 00:34:28 UTC, ketmar wrote:
>>>> 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).
>>>
>>> I tried that like so:
>>>
>>> https://gist.github.com/FatalCatharsis/39c5f35ae78ecd5399eebe0fb2491004
>>>
>>> I put exception blocks both around main and around the invocation of 
>>> the hash lookup and still get no printouts anywhere, including at the 
>>> beginning and end of main.
>>
>> 'cause you never printed anything.
> 
> the writeln("start"); and writeln("end"); in main. This is what I meant 
> by printing. These do not appear in the output. The programs starts and 
> immediately ends without printing "start" and "end".

try flushing the output. In some cases the output streams do not flush 
on newlines.

> I did not put an 
> output in the exception handler of the WndProc because writeln can throw 
> and the function is marked nothrow. All I as trying to do there was get 
> it to recover.

Just surround writeln with try/catch(Exception), should work.

You could also just use good old printf.

-Steve


More information about the Digitalmars-d mailing list