propellor/src/Propellor/Exception.hs

19 lines
494 B
Haskell

{-# LANGUAGE PackageImports #-}
module Propellor.Exception where
import Propellor.Types
import Propellor.Message
import Utility.Exception
import Control.Exception (IOException)
-- | Catches IO exceptions and returns FailedChange.
catchPropellor :: Propellor Result -> Propellor Result
catchPropellor a = either err return =<< tryPropellor a
where
err e = warningMessage (show e) >> return FailedChange
tryPropellor :: Propellor a -> Propellor (Either IOException a)
tryPropellor = try