[Issue 13543] std.file.FileException has useless __FILE__ and __LINE__ arguments tacked on
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Sep 27 15:35:41 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13543
--- Comment #5 from bearophile_hugs at eml.cc ---
(In reply to bearophile_hugs from comment #3)
> If I open a file, and the opening fails, I'd like the
> exception to tell me what damned line of my code has tried to open that
> file.
- - - - - - - - - - - - - - -
A Python script (both files are missing):
f1 = open("some_file1.txt")
f2 = open("some_file2.txt")
Gives information that helps to locate what's the line that has tried to open
the missing file:
Traceback (most recent call last):
File "...\test.py", line 1, in <module>
f1 = open("some_file1.txt")
IOError: [Errno 2] No such file or directory: 'some_file1.txt'
- - - - - - - - - - - - - - -
A similar D program gives line number inside the library code, but I'd like an
exception that tells me that the problem is in test.d at line 3:
void main() {
import std.stdio;
auto f1 = File("some_file1.txt");
auto f2 = File("some_file2.txt");
}
std.exception.ErrnoException at std\stdio.d(364): Cannot open file
`some_file1.txt' in mode `rb' (No such file or directory)
----------------
0x0040447B in @safe shared(core.stdc.stdio._iobuf)*
std.exception.__T12errnoEnforceTPOS4core4stdc5stdio6_iobufVAyaa11_7374645c737464696f2e64Vki364Z.errnoEnforce(shared(core.stdc.stdio._iobuf)*,
lazy immutable(char)[])
...
- - - - - - - - - - - - - - -
--
More information about the Digitalmars-d-bugs
mailing list