[Haskell-cafe] How to catch all exceptions that could be caught?
sol at typeful.net
Thu Jan 12 08:07:55 CET 2012
> > Use SomeException for the type, as it is the base of the exception
> > hierarchy.
> But it is usually recommended that you *don't* do this, as it even
> captures Ctrl-c invocations:
I think there are situation when it is justified to catch almost all
exceptions. And people do that a lot, which often leads to ctrl-c not
properly working (e.g. we had this in HUnit before 22.214.171.124). The way I
deal with this is:
someAction `catches` [
-- Re-throw AsyncException, otherwise execution will not terminate
-- on SIGINT (ctrl-c). All AsyncExceptions are re-thrown (not
-- just UserInterrupt) because all of them indicate severe
-- conditions and should not occur during normal operation.
Handler (\e -> throw (e :: AsyncException)),
Handler (\e -> yourHandler $ e :: SomeException)
More information about the Haskell-Cafe