https://issues.dlang.org/show_bug.cgi?id=13543
--- Comment #9 from Walter Bright <[email protected]> --- (In reply to bearophile_hugs from comment #8) > 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. I doubt I'd have trouble locating a 'throw' statement in a 50 line program. I don't believe you would, either. > 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. Sorry, I think this is rubbish. (You also do not want to catch Exception messages just to filter out the file/line to then present the message to the user.) > > 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, Console apps don't need to that, and it's pretty easy for a gui app to provide a top level handler that pops up a 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 Again, Exceptions are NOT A DEBUGGING TOOL and should NOT BE THROWN WHEN BUGS ARE DETECTED. Use asserts for that. Asserts are designed for that, and are pretty good at it. --
