[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:58:45 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13543

--- Comment #8 from bearophile_hugs at eml.cc ---
(In reply to Walter Bright from comment #7)

> 1. You are trying to use exceptions to debug the program. This is utterly
> wrong.

It's what millions of people are doing every day in Python, Ruby, etc. If you
are writing a 50 lines long script program that loads some files, you are
thankful when the exception tells you what line of your code has opened a
missing file.

In such small D programs you don't want to add assert(isOpen(...) &&
isWriteable(...)) and even if you do that, there are other problems, like
asserts and file ops getting out of sync, file state changing between the
assert and the file operation, etc.


> 2. Exceptions are meant to provide information to the user of the app, not
> the programmer of the app.

As an user of the app, the app should tell me that a file is missing with a
nice pop up window, or better, not with exceptions. But not all D programs are
large, and giving the line number in the exception message is a first basic
information when the code has bugs or when the D program is not an app, but a
little script-like (and I write many such tiny D programs).

--


More information about the Digitalmars-d-bugs mailing list