[phobos] Calling abort() on unhandled exception
Leandro Lucarella
luca at llucax.com.ar
Fri Jul 30 06:54:20 PDT 2010
Andrei Alexandrescu, el 29 de julio a las 22:01 me escribiste:
> Sean Kelly wrote:
> >On Jul 29, 2010, at 9:37 PM, Andrei Alexandrescu wrote:
> >
> >>Sean Kelly wrote:
> >>>On Jul 29, 2010, at 8:21 PM, Walter Bright wrote:
> >>>>Andrei Alexandrescu wrote:
> >>>>>Walter Bright wrote:
> >>>>>>I think we misunderstand each other. A file copy program
> >>>>>>that fails due to, say, the disk being full, should not
> >>>>>>produce a core dump. It should produce an error message
> >>>>>>like:
> >>>>>>
> >>>>>>error: disk full
> >>>>>>
> >>>>>>An uncaught exception is NOT an invalid or crashed program
> >>>>>> in D.
> >>>>>I think Sean talks about Throwable objects that are not
> >>>>>Exception objects.
> >>>>>
> >>>>It's reasonable for seg fault exceptions to produce a core
> >>>>dump. It isn't for recoverable Exceptions, or for
> >>>>non-recoverable ones like out of memory.
> >>>At the moment, we don't differentiate between seg faults and
> >>>non-recoverable errors. Though seg faults are only thrown as
> >>>exceptions on Windows which doesn't have core dumps anyway, as
> >>>far as I know. For what it's worth, I was investigating this
> >>>bug:
> >>> http://d.puremagic.com/issues/show_bug.cgi?id=4385
> >>I see. Overall, my opinion is that regular exceptions that
> >>escape main(0 should simply print their error message to stderr
> >>and exit(1). There should be no stack trace, abort(), core dump,
> >>or anything worse than that. Print the string and exit(1).
> >>Anything more will force most people to actually insert a
> >>try/catch in main
> >> to do the simple thing.
> >
> >I think the stack trace at least should remain. People have been
> >begging for that for years, and I do think it's pretty useful.
> >Simply
> >printing an error message says nothing about the context, and it's
> >context that gives error messages meaning.
>
> 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.
That's not an exception!!!! What's the point of that???? Why don't you
just write a library function like like enforce but that uses exit(1)
instead of throwing an exception for that?!?!?! You really want to
sacrifice the correct behavior for this dumb, dumb "feature"???
This really makes me mad! God...
Plus *ANY* other programming language mark uncaught exceptions as
OBVIOUS ERRORS (they print traces or abort()).
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
El día que falten los niños, que sobren las mujeres y que se prenda
fuego el último árbol, será el Apocalípsis.
-- Ricardo Vaporeso. Camino Negro, 1916.
More information about the phobos
mailing list