FileException Inconsistency?

Alex alexander.edwards at gmail.com
Mon May 11 11:11:07 UTC 2026


On Monday, 11 May 2026 at 10:40:27 UTC, Nick Treleaven wrote:
> On Monday, 11 May 2026 at 04:18:33 UTC, Alex wrote:
>>         catch (FileException fe) {
>>             writeln("File Exception: ", fe);
>
> You might want to change `fe` to `fe.msg`, otherwise it will 
> print the stack trace too, which is confusing.

Thanks for your replies and tip on '.msg'.

The code "works" but my concern is simply that the file 
permission access error resuts in either a desirable 
FileException if there's a writeln() around, or a brutish 
Throwable std.file.FileException if there isn't a writeln() for 
some reason.  Just seems very strange that the FileException 
isn't created and handled the same both ways as I would expect.

I don't think it should have to catch a Throwable and decode a 
std.file.FileException into what looks like should be caught by 
the catch (FileException fe) {} for the same error?

Cheers


More information about the Digitalmars-d-learn mailing list