summaryrefslogtreecommitdiff
path: root/src/Propellor/Exception.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Exception.hs')
-rw-r--r--src/Propellor/Exception.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs
index 3ab783bf..2e8754dc 100644
--- a/src/Propellor/Exception.hs
+++ b/src/Propellor/Exception.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE CPP, ScopedTypeVariables #-}
module Propellor.Exception where
@@ -8,11 +8,14 @@ import Propellor.Message
import Utility.Exception
import Control.Exception (AsyncException)
+#if MIN_VERSION_base(4,7,0)
+import Control.Exception (SomeAsyncException)
+#endif
import Control.Monad.Catch
import Control.Monad.IO.Class (MonadIO)
-- | Catches all exceptions (except for `StopPropellorException` and
--- `AsyncException`) and returns FailedChange.
+-- `AsyncException` and `SomeAsyncException`) and returns FailedChange.
catchPropellor :: (MonadIO m, MonadCatch m) => m Result -> m Result
catchPropellor a = either err return =<< tryPropellor a
where
@@ -21,6 +24,9 @@ catchPropellor a = either err return =<< tryPropellor a
catchPropellor' :: MonadCatch m => m a -> (SomeException -> m a) -> m a
catchPropellor' a onerr = a `catches`
[ Handler (\ (e :: AsyncException) -> throwM e)
+#if MIN_VERSION_base(4,7,0)
+ , Handler (\ (e :: SomeAsyncException) -> throwM e)
+#endif
, Handler (\ (e :: StopPropellorException) -> throwM e)
, Handler (\ (e :: SomeException) -> onerr e)
]