Actually, would this be safe to use? :<br><br> try<br> {<br> fun();<br> }<br> catch (Exception e)<br> {<br> writeln("Primary exception: ", typeid(e));<br> <br> while ((e = cast(Exception)e.next) !is null)<br>
{<br> writeln("Collateral exception: ", typeid(e));<br> } <br> }<br><br><br><br><div class="gmail_quote">On Thu, Aug 19, 2010 at 10:18 PM, Andrej Mitrovic <span dir="ltr"><<a href="mailto:andrej.mitrovich@gmail.com">andrej.mitrovich@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">That goes against the statement in TDPL that user code should never catch Throwable's, unless absolutely necessary. So in case of collateral exceptions, we are forced to catch Throwable anyway?<div>
<div></div><div class="h5"><br><br><div class="gmail_quote">
On Thu, Aug 19, 2010 at 10:00 PM, Sean Kelly <span dir="ltr"><<a href="mailto:sean@invisibleduck.org" target="_blank">sean@invisibleduck.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>Andrej Mitrovic Wrote:<br>
<br>
> TDPL code that should work:<br>
</div>...<br>
<div>> Errors out:<br>
> (49): Error: cannot implicitly convert expression (e.next) of type object.Throwable to object.Exception<br>
><br>
> Why would the return type of e.next be Throwable if e is an Exception type?<br>
<br>
</div>Because e.next is a Throwable reference inherited from Throwable:<br>
<br>
class Throwable {<br>
Throwable next;<br>
}<br>
<br>
class Error : Throwable {}<br>
class Exception : Throwable {}<br>
<br>
Because collateral exceptions could be both Errors and Exceptions, I don't think the sample code can work exactly as written.<br>
</blockquote></div><br>
</div></div></blockquote></div><br>