Collateral Exceptions, Throwable vs Exception

Mike Parker aldacron at gmail.com
Fri Aug 20 06:13:10 PDT 2010


Andrei Alexandrescu wrote:
> On 08/19/2010 10:14 PM, Mike Parker wrote:
>> Sean Kelly wrote:
>>> The .next property is to allow chaining. However, it may be that the
>>> current behavior of toString is incorrect, or that a new function
>>> should be added that only returns a string describing the current
>>> exception and not the entire chain.
>>>
>>
>> IMO, it should be the opposite. I noticed the current behavior the other
>> day and was surprised. I would expect toString to return only the
>> message from the Throwable I called it on. A concatenated string of
>> messages from the whole chain would be the special case to be separated
>> into a convenience function. Then again, I don't see the convenience
>> function being necessary, as it's trivial to roll your own for the cases
>> when you want it -- which is what I was doing when I discovered the
>> current behavior and, like Andrej, was confronted by a long list of
>> exception messages.
> 
> My opinion: Throwable should have a @property called printingDepth or 
> something. It should default to e.g. 3 (or conservatively at 1) and 
> limit the number of exceptions in a chain formatted in toString().
> 
> Andrei

Yes, that's better. +1.


More information about the Digitalmars-d mailing list