Collateral Exceptions, Throwable vs Exception

Sean Kelly sean at invisibleduck.org
Thu Aug 19 13:00:09 PDT 2010


Andrej Mitrovic Wrote:

> TDPL code that should work:
...
> Errors out:
> (49): Error: cannot implicitly convert expression (e.next) of type object.Throwable to object.Exception
> 
> Why would the return type of e.next be Throwable if e is an Exception type?

Because e.next is a Throwable reference inherited from Throwable:

class Throwable {
    Throwable next;
}

class Error : Throwable {}
class Exception : Throwable {}

Because collateral exceptions could be both Errors and Exceptions, I don't think the sample code can work exactly as written.


More information about the Digitalmars-d mailing list