Publicly exposing an exception a module throws
Shriramana Sharma via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 17 02:35:37 PDT 2015
If a module's function throws an exception, shouldn't that module publicly
import that exception? Please observe:
$ cat errnoexception.d
import std.stdio;
//import std.exception;
void main()
{
File file;
try file = File("/non-existent-file");
catch (ErrnoException e) {}
}
$ dmd errnoexception.d
errnoexception.d(8): Error: undefined identifier 'ErrnoException'
Uncommenting the import of std.exception solves the problem, but I believe
it would make sense to have the exception *publicly* imported into std.stdio
to avoid having the user to manually import it. Agreed?
(Currently the exception is just thrown in stdio.d by errnoEnforce in l 385
which is imported at l 383.)
--
Shriramana Sharma, Penguin #395953
More information about the Digitalmars-d
mailing list