summaryrefslogtreecommitdiff
path: root/src/Propellor/Exception.hs
diff options
context:
space:
mode:
authorJoey Hess2016-06-20 10:51:42 -0400
committerJoey Hess2016-06-20 10:51:42 -0400
commitf0fbdce8fd8369eaa78dfff02aca79fb61170931 (patch)
tree6cb62ca562ad7b609b30c539153e471b0207c5e8 /src/Propellor/Exception.hs
parent3a851213ad440476a37d2a318c4371b9e2c34ce2 (diff)
handle SomeAsyncException same as AsyncException
This new type was added to base a while ago; I don't know what uses it, but it's intended to be an async exception, so make sure we don't catch it.
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)
]