diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-06-20 10:51:42 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-06-20 10:51:42 -0400 |
| commit | f0fbdce8fd8369eaa78dfff02aca79fb61170931 (patch) | |
| tree | 6cb62ca562ad7b609b30c539153e471b0207c5e8 /src | |
| parent | 3a851213ad440476a37d2a318c4371b9e2c34ce2 (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')
| -rw-r--r-- | src/Propellor/Exception.hs | 10 | ||||
| -rw-r--r-- | src/Utility/Exception.hs | 8 |
2 files changed, 15 insertions, 3 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) ] diff --git a/src/Utility/Exception.hs b/src/Utility/Exception.hs index e691f13b..f6551b45 100644 --- a/src/Utility/Exception.hs +++ b/src/Utility/Exception.hs @@ -5,7 +5,7 @@ - License: BSD-2-clause -} -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE CPP, ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-tabs #-} module Utility.Exception ( @@ -28,6 +28,9 @@ module Utility.Exception ( import Control.Monad.Catch as X hiding (Handler) import qualified Control.Monad.Catch as M import Control.Exception (IOException, AsyncException) +#if MIN_VERSION_base(4,7,0) +import Control.Exception (SomeAsyncException) +#endif import Control.Monad import Control.Monad.IO.Class (liftIO, MonadIO) import System.IO.Error (isDoesNotExistError, ioeGetErrorType) @@ -74,6 +77,9 @@ bracketIO setup cleanup = bracket (liftIO setup) (liftIO . cleanup) catchNonAsync :: MonadCatch m => m a -> (SomeException -> m a) -> m a catchNonAsync a onerr = a `catches` [ M.Handler (\ (e :: AsyncException) -> throwM e) +#if MIN_VERSION_base(4,7,0) + , M.Handler (\ (e :: SomeAsyncException) -> throwM e) +#endif , M.Handler (\ (e :: SomeException) -> onerr e) ] |
