{-# LANGUAGE ScopedTypeVariables #-}
module Control.Exc (ignoringException, printingException, orException)
where
import Prelude
import Control.Exception (catch, SomeException)
ignoringException :: IO (Maybe a) -> IO (Maybe a)
ignoringException f = f `catch` ignore
where ignore (_ :: SomeException) = return Nothing
printingException :: String -> 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