[D-runtime] [D-Programming-Language/druntime] a46f58: Changed Throwable.toString to only print the curre...

Sean Kelly sean at invisibleduck.org
Wed Apr 13 16:47:00 PDT 2011


On Apr 13, 2011, at 3:54 PM, Jonathan M Davis wrote:

>> Changed Throwable.toString to only print the current exception, not the
>> entire chain. Also added support for Error.bypassedException in the
>> uncaught exception display code.
> 
> When an exception gets printed on the command line because it escaped main, it 
> really should be printing the whole chain (which, unfortunately, it's never 
> done in my experience). Does making toString print only one exception make it 
> so that escaped exceptions will only end up with the one exception being 
> printed instead of the whole chain, or are the Throwables specifically 
> iterated over to print the whole chain? It would probably be best to have 
> toString print just that Throwable and then have the handler iterate through 
> all of the Throwables in the chain, but I'd very much like to see the whole 
> chain getting printed and I hope that this change does not work against that.

It's always printed the entire chain for me.  What was broken until recently was the chaining itself, but that's been fixed.  If printing the chain of exceptions doesn't work for you with the latest druntime, give me a test case and platform type to verify (though platform shouldn't matter--that code isn't versioned).

I changed the behavior of toString because it should really only print info on the current object.  What I did to replace the old functionality was explicitly iterate across the chain in src/rt/dmain2.d, so toString isn't called any more.  This may still not be right--it's possible that I should iterate across the exceptions and print the result of toString for each one.  But that risks an inconsistent exception trace if the user has overridden toString.  For now I decided to go with consistent output.


More information about the D-runtime mailing list