[phobos] Calling abort() on unhandled exception

Leandro Lucarella luca at llucax.com.ar
Fri Jul 30 09:21:42 PDT 2010



Sean Kelly, el 30 de julio a las 07:42 me escribiste:
> On Jul 29, 2010, at 10:01 PM, Andrei Alexandrescu wrote:
> > 
> > I for one really enjoy stuff like:
> > 
> > void main(string[] args)
> > {
> >    enforce(args.length > 1, "Usage: prog arg");
> >    ...
> > }
> > 
> > Having a stack trace tacked there... not good. Exception messages
> > are meant to be seen by users. Stack traces are meant to be seen by
> > the programmer. The fact that we print both by default doesn't sit
> > well at all.
> 
> Fair enough.  Maybe they should only be displayed for Errors, not Exceptions?

No, it's not fair enough, that code is wrong, wrong, wrong. There is no
reason not to call exit(1) for handling that kind of errors.

If you *REALLY REALLY* want some kind of exception to be caught by main
and just print a nice message, make it explicit. Add a standard
exception, like UserErrorException, and catch only *that* exception, not
*ANY* exception. Then Andrei can be happy and write horrible code that
throws a UserErrorException instead of using exit().

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
A veces quisiera ser un auto,
para chocar como choco siendo humano,
para romperme en mil pedazos.



More information about the phobos mailing list