On 10/1/2014 6:44 AM, Bruno Medeiros wrote:
This is incorrect.

Yes, the primary purpose of Exceptions is not for debugging, but to report
exceptional state to the user (or some other component of the system).

But they also have a purpose for debugging, particularly the stack traces of
exceptions. Take what you said:

"Failure to respond properly to an input/environmental error is a bug.
But the input/environmental error is not a bug. If it was, then the
program should assert on the error, not throw. "

So, some component/function Foo detects an environmental error, and throws and
Exception, accordingly. Foo is not responsible for handling these errors, but
some other component is.

Component/function Bar is the one that should handle such an error (for example,
it should display a dialog to the user, and continue the application). But due
to a bug, it doesn't do so, and the Exception goes all the way through main().

This is like saying "if statements are for debugging".


The programmer notices this happening, and clearly recognizes it's a bug (but
doesn't know where the bug is, doesn't know that it's Bar that should be
handling it). Now, what is best, to just have the Exception message (something
like "File not found") displayed to the programmer - or even an end-user that
could report a bug -, or to have the stack trace of the Exception so that the
programmer can more easily look at which function should be handling it?

Would you agree that every time DMD reports a syntax error in user code, it should also include a stack trace of the DMD source code to where in DMD it reported the error?

Reply via email to