<div dir="ltr">I reported this here some time ago: <a href="http://d.puremagic.com/issues/show_bug.cgi?id=11501">http://d.puremagic.com/issues/show_bug.cgi?id=11501</a> (dup of <a href="http://d.puremagic.com/issues/show_bug.cgi?id=8298">http://d.puremagic.com/issues/show_bug.cgi?id=8298</a>)<div>
and there's a pull request ready, not sure why it isn't being merged</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 5, 2014 at 10:20 PM, dennis <span dir="ltr"><<a href="mailto:dennisr@visi.com" target="_blank">dennisr@visi.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sunday, 5 January 2014 at 21:33:56 UTC, FreeSlave wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You must not cast base class to derived class, when you don't know actual type (and even if you know exact type it's still bad practice to cast instance of more generic type to more specific one). Use multiple catch statements instead:<br>

<br>
catch(FileException o)<br>
{<br>
//handle FileException<br>
}<br>
catch(Exception o)<br>
{<br>
//handle all other types of exceptions<br>
}<br>
<br>
About dirEntries, you need to move your try/catch statements into loop somehow. You probably should save result of dirEntries to variable and then make manual loop instead of foreach. Result of dirEntries is lazy, so it will not throw exception when you just get it.<br>

<br>
It may look like<br>
<br>
auto entries = dirEntries(your args);<br>
while(!entries.empty)<br>
{<br>
    try<br>
    {<br>
        entry = entries.front;<br>
        //do your stuff<br>
    }<br>
    //"catch" statements<br>
    finally<br>
    {<br>
        entries.popFront();<br>
    }<br>
}<br>
</blockquote>
<br></div></div>
Thank you for the quick feedback.  Your explanation of the two problems works for me.<br>
</blockquote></div><br></div>