Silent error when using hashmap

FatalCatharsis via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 26 19:30:17 PDT 2017


On Thursday, 27 July 2017 at 01:21:40 UTC, Steven Schveighoffer 
wrote:
>> 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

This appears to be it. When an error is thrown, stdout does not 
flush. When I put stdout.flush() immediately after the 
writeln("start") at the beginning it is printed correctly. 
However, when I try to catch the error and then do stdout.flush() 
in main, it does not print.

Do you know of a way to make D always flush the output buffer 
when an error is thrown?

On Thursday, 27 July 2017 at 01:05:28 UTC, ketmar wrote:
> 'cause, as i said, RangeError is not an exception. i thought 
> that you already know it, as this is "general", not "learning" 
> NG.

Yes, I understand this. This is not my question. My question is 
why all previous output to the console does not occur before the 
error is thrown. As Steve said, this is because the output buffer 
is not flushed when an error occurs.



More information about the Digitalmars-d mailing list