diff options
| author | Joey Hess <joey@kitenet.net> | 2014-05-14 19:47:17 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-05-14 19:47:17 -0400 |
| commit | 39217c55690de5641a9fe4ef2236d6127ebbcbb3 (patch) | |
| tree | 31284fd462e2d02cf9bf0b8077c0e8dd34181988 /src/Propellor/Exception.hs | |
| parent | eb6e6fe11290971b37a18d9a78f6d9b78228c06f (diff) | |
| parent | 7115d1ec162b4059b3e8e8f84bd8d5898c1db025 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Exception.hs')
| -rw-r--r-- | src/Propellor/Exception.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs new file mode 100644 index 00000000..f6fd15f1 --- /dev/null +++ b/src/Propellor/Exception.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE PackageImports #-} + +module Propellor.Exception where + +import qualified "MonadCatchIO-transformers" Control.Monad.CatchIO as M +import Control.Exception + +import Propellor.Types +import Propellor.Message + +-- | 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 = M.try |
