summaryrefslogtreecommitdiff
path: root/src/Propellor/Exception.hs
blob: 2b38af0c2f8e8e14531d377692cad6d30ccc71bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{-# 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