Created attachment 1492
the example code
Say we want to overwrite a file "test.txt".
Say we instead have a typo and so open it for reading.
After trying to write to the file, a hilarious message appears:
-----
std.exception.ErrnoException@<somepath>\std\stdio.d(2113): (No error)
-----
The culprit (line 2337 of stdio.d at master currently) is:
-----
if (result != writeme.length) errnoEnforce(0);
-----
That errnoEnforce(0) produces a nonsense message "...ErrnoException...: (No error)".
Which I believe is wrong code regardless of the context.
But I don't know which way of reporting the error is right here.
Below is the complete example code.
The file "test.txt" must be present for it to work.
Its contents may be arbitrary.
-----
import std.stdio;
void main ()
{
auto f = File ("test.txt", "rt"); // file must exist
f.writeln ("!");
}
-----
Comment #1 by b2.temp — 2017-12-26T09:59:32Z
It gives:
std.exception.ErrnoException@/usr/include/dmd/phobos/std/stdio.d(2847): (Bad file descriptor)
nowadays