- Catch(...) and rethrow<p><a href="http://www.nedbatchelder.com/blog/200310.html">Ned Batchelder</a> said that he didn't approve of the catch(...) but I think it's necessary in this particular instance. This is because when the UpdateRegistry method fails <em>for any reason</em>, the CopyFiles must be undone.</p>
<p>What I missed is re-throwing the exception after fixing the stuff I knew I had to fix:</p>
<p><font face="Courier New" size="2"> } catch (...)<br /> {<br /> UnCopyFiles();<br /> UnUpdateRegistry();<br /> throw;</font><font face="Courier New" size="2"><br /></font><font face="Courier New" size="2"> }</font></p>
<p>If there are other specific error conditions that you can handle and eat (de-escalating them from exceptions to return codes) then you'd want to do that in a separate catch block.</p>
<p><font face="Courier New" size="2"></font> </p>Thu, 01 Sep 2005 19:17:04 GMT