From c1b8fa2c397355076323c97c976b7d2cfd46504c Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Wed, 13 Jan 2016 03:06:21 +0100 Subject: Don't fail when cabal sandbox pkgdb doesn't exist --- CabalHelper/Compile.hs | 3 ++- CabalHelper/Log.hs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'CabalHelper') diff --git a/CabalHelper/Compile.hs b/CabalHelper/Compile.hs index 54771b1..59bb48c 100644 --- a/CabalHelper/Compile.hs +++ b/CabalHelper/Compile.hs @@ -97,7 +97,8 @@ compileHelper opts cabalVer projdir distdir = withHelperSources $ \chdir -> do compileSandbox :: FilePath -> MaybeT IO (Either ExitCode FilePath) compileSandbox chdir = do sandbox <- MaybeT $ getSandboxPkgDb projdir (display buildPlatform) =<< ghcVersion opts - ver <- MaybeT $ find (== cabalVer) <$> listCabalVersions' opts (Just sandbox) + ver <- MaybeT $ logSomeError opts "compileSandbox" $ + find (== cabalVer) <$> listCabalVersions' opts (Just sandbox) vLog opts $ logMsg ++ "sandbox package-db" liftIO $ compileWithPkg chdir (Just sandbox) ver diff --git a/CabalHelper/Log.hs b/CabalHelper/Log.hs index 9e04df0..bbc84a6 100644 --- a/CabalHelper/Log.hs +++ b/CabalHelper/Log.hs @@ -2,6 +2,7 @@ module CabalHelper.Log where import Control.Monad import Control.Monad.IO.Class +import Control.Exception as E import Data.String import System.IO import Prelude @@ -12,3 +13,9 @@ vLog :: MonadIO m => Options -> String -> m () vLog Options { verbose = True } msg = liftIO $ hPutStrLn stderr msg vLog _ _ = return () + +logSomeError :: Options -> String -> IO (Maybe a) -> IO (Maybe a) +logSomeError opts label a = do + a `E.catch` \se@(SomeException _) -> do + vLog opts $ label ++ ": " ++ show se + return Nothing -- cgit v1.2.3