matterhorn-50200.11.0: src/Matterhorn/IOUtil.hs
module Matterhorn.IOUtil
( convertIOException
)
where
import Prelude ()
import Matterhorn.Prelude
import Control.Exception
import Control.Monad.Trans.Except
import System.IO.Error ( ioeGetErrorString )
convertIOException :: IO a -> ExceptT String IO a
convertIOException act = do
result <- liftIO $ (Right <$> act) `catch`
(\(e::IOError) -> return $ Left $ ioeGetErrorString e)
case result of
Left e -> throwE e
Right v -> return v