[phobos] Calling abort() on unhandled exception

Andrei Alexandrescu andrei at erdani.com
Fri Jul 30 17:42:51 PDT 2010


Michel Fortin wrote:
> Le 2010-07-30 à 1:01, Andrei Alexandrescu a écrit :
> 
>> Exception messages are meant to be seen by users.
> 
> I disagree.
> 
> The error message of an exception might be meaningful in a small
> program that does only one thing at a time, but in general to give
> the user an understandable error message you need more context
> information.

I agree. That doesn't make the exception's own message unneeded or 
unnecessary. It should be at most embellished.

> So I believe in the vast majority of cases calling abort() and
> showing a stack trace is what you want. That's what most other
> languages do. It's easy to get what Andrei wants with a "try {...}
> catch (Exception e) { writeln(e); exit(-1); }" in the main, but I'd
> generally recommend against this.

It's not that I want. It's an important use of the language. You could 
argue that D should not attempt to attempt scripting, but I think it 
should. That implies an ability to write short programs that do useful 
things.


Andrei


More information about the phobos mailing list