<div dir="ltr">There&#39;s a pattern that arises fairly often: catching every exception thrown by code. The naive approach is to do something like:<div><br></div><div>    result &lt;- try someCode</div><div>    case result of</div>

<div>        Left (e :: SomeException) -&gt; putStrLn $ &quot;It failed: &quot; ++ show e</div><div>        Right realValue -&gt; useRealValue</div><div><br></div><div>This seems perfectly valid, except that it catches a number of exceptions which seemingly should <i>not</i> be caught. In particular, it catches the async exceptions used by both killThread and timeout.</div>

<div><br></div><div>I think it&#39;s fair to say that there&#39;s not going to be a single function that solves all cases correctly, but it is a common enough situation that people need to write code that resumes work in the case of an exception that I think we need to either have some guidelines for the right approach here, or perhaps even a utility function along the lines of:</div>

<div><br></div><div>    shouldBeCaught :: SomeException -&gt; Bool</div><div><br></div><div>One first stab at such a function would be to return `False` for AsyncException and Timeout, and `True` for everything else, but I&#39;m not convinced that this is sufficient. Are there any thoughts on the right approach to take here?</div>

</div>