catch package:exceptions

Provide a handler for exceptions thrown during execution of the first action. Note that type of the type of the argument to the handler will constrain which exceptions are caught. See Control.Exception's catch.
This module supports monads that can throw extensible exceptions. The exceptions are the very same from Control.Exception, and the operations offered very similar, but here they are not limited to IO. This code is in the style of both transformers and mtl, and is compatible with them, though doesn't mimic the module structure or offer the complete range of features in those packages. This is very similar to ExceptT and MonadError, but based on features of Control.Exception. In particular, it handles the complex case of asynchronous exceptions by including mask in the typeclass. Note that the extensible exceptions feature relies on the RankNTypes language extension.
Catches all exceptions, and somewhat defeats the purpose of the extensible exception system. Use sparingly. NOTE This catches all exceptions, but if the monad supports other ways of aborting the computation, those other kinds of errors will not be caught.
Catch all IOError (eqv. IOException) exceptions. Still somewhat too general, but better than using catchAll. See catchIf for an easy way of catching specific IOErrors based on the predicates in System.IO.Error.
Catch exceptions only if they pass some predicate. Often useful with the predicates for testing IOError values in System.IO.Error.
A more generalized way of determining which exceptions to catch at run time.
Catches different sorts of exceptions. See Control.Exception's catches
Add Exception handling abilities to a Monad. This should never be used in combination with IO. Think of CatchT as an alternative base monad for use with mocking code that solely throws exceptions via throwM. Note: that IO monad has these abilities already, so stacking CatchT on top of it does not add any value and can possibly be confusing:
>>> (error "Hello!" :: IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)
Hello!
>>> runCatchT $ (error "Hello!" :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)
*** Exception: Hello!
>>> runCatchT $ (throwM (ErrorCall "Hello!") :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)
Hello!
A class for monads which allow exceptions to be caught, in particular exceptions which were thrown by throwM. Instances should obey the following law:
catch (throwM e) f = f e
Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannot be used by those monads to properly implement a function such as finally. For more information, see MonadMask.
Map the unwrapped computation using the given function.
runCatchT (mapCatchT f m) = f (runCatchT m)