module Control.Exc (ignoringException, printingException, orException)
where
#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 706)
import Prelude
#else
import Prelude hiding (catch)
#endif
import Control.Exception (catch, SomeException)
ignoringException :: IO (Maybe a) -> IO (Maybe a)
ignoringException f = f `catch` ignore
where ignore (_ :: SomeException) = return Nothing
printingException :: [Char] -> IO a -> IO a
printingException desc f = f `catch` handler
where handler (err :: SomeException) = fail $ concat [desc, " failed: ", show err]
orException :: IO a -> IO a -> IO a
orException f g = f `catch` handler
where handler (_ :: SomeException) = g