How to robustly call third-party code in the presence of exceptions?
<p>In a language which uses exceptions to signal errors, I want to call some third-party code and, if it fails, run fallback code instead. For example:</p>

<pre><code>try:
    result = third_party.fast_calculation()
catch:
    result = slower_calculation()
</code></pre>

<p>In my experience, it is very rare to know all of the exceptions that could be thrown by the third-party code. Therefore I cannot list these exceptions in the <code>catch</code> clause. On the other hand, I am frequently advised not to <code>catch</code> every possible exception.</p>

<p>How should I write the <code>catch</code> clause in this situation?</p>