[phobos] Calling abort() on unhandled exception

Steve Schveighoffer schveiguy at yahoo.com
Fri Jul 30 07:50:22 PDT 2010


Um, no.  Exceptions can easily be uncaught (oops, forgot a try catch!).  I don't 
want the end result of an uncaught exception to be a bug that's impossible or 
difficult to determine because no stack trace was printed.  Let's consider that 
an exception may not be easily repeated and is most likely encountered by a 
user, not a developer.  Giving a mechanism to communicate the problem as 
completely as possible from the user developer should be the default.

We should classify any exception or error that gets thrown outside of main to be 
an exception that was not planned for by the developer, and therefore a program 
error.  This should trigger as much info as possible, definitely including a 
stack trace, and possibly a core dump (though, dumping core after catching an 
exception is next to useless).

If you want to avoid printing stack traces, catch the exception inside of main.  
I don't think it's too much to ask.

-Steve



----- Original Message ----
> From: Sean Kelly <sean at invisibleduck.org>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> Sent: Fri, July 30, 2010 10:42:51 AM
> Subject: Re: [phobos] Calling abort() on unhandled exception
> 
> 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?
> 
> > Is it reasonable to  say that Exception is the "nicer" thing and Throwable is 
>the "less nice" thing  that is handled differently? Then come bus errors, which 
>are "not nice at  all".
> 
> It is.
> _______________________________________________
> phobos  mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
> 


      


More information about the phobos mailing list