Collateral Exceptions, Throwable vs Exception

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 23 05:03:09 PDT 2010


On Thu, 19 Aug 2010 18:48:15 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 08/19/2010 03:45 PM, Andrej Mitrovic wrote:
>> Yes, I've added it as Throwable. But there's one more problem with
>> your code, this:
>>
>> catch (Throwable e)     // have to use Throwable for collateral  
>> exceptions
>>                              // or maybe use a cast like below
>>      {
>>          writeln("Primary exception: ", typeid(e), " ", e);
>>
>>          while ((e = e.next) !is null)
>>          {
>>              writeln("Collateral exception: ", typeid(e), " ", e);
>>          }
>>      }
>>
>> Will output ~5000 lines of "Exception .." stuff. Oh and in the book it
>> looks like you're counting from 100 to 1 (for the throws from gun),
>> which makes sense. Yet I'm getting back output from 1 to 100. Not sure
>> what's going on there..
>
> The reverse ordering seems to be a bug in the implementation.

Don't have the book in front of me, but it is important that collateral  
exceptions be ordered in reverse order of insertion, otherwise, adding a  
collateral exception involves a linear search to the end of the linked  
list.

-Steve


More information about the Digitalmars-d mailing list