From 8f3fb2a7d7aee23101f75e47bf995d713389c127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 18 Apr 2014 13:20:00 +0200 Subject: [PATCH] Only supress stderr on success --- Language/Haskell/GhcMod/GhcPkg.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Language/Haskell/GhcMod/GhcPkg.hs b/Language/Haskell/GhcMod/GhcPkg.hs index cb790be..d38eb39 100644 --- a/Language/Haskell/GhcMod/GhcPkg.hs +++ b/Language/Haskell/GhcMod/GhcPkg.hs @@ -18,9 +18,10 @@ import Data.Char (isSpace,isAlphaNum) import Data.List (isPrefixOf, intercalate) import Data.Maybe (listToMaybe, maybeToList) import Language.Haskell.GhcMod.Types -import Language.Haskell.GhcMod.Utils import System.FilePath (()) -import System.Process (readProcess) +import System.Process (readProcessWithExitCode) +import System.IO (hPutStrLn,stderr) +import System.Exit (ExitCode(..)) import Text.ParserCombinators.ReadP (ReadP, char, between, sepBy1, many1, string, choice, eof) import qualified Text.ParserCombinators.ReadP as P @@ -67,7 +68,13 @@ ghcPkgList dbs = map fst3 <$> ghcPkgListEx dbs ghcPkgListEx :: [GhcPkgDb] -> IO [Package] ghcPkgListEx dbs = do - output <- suppressStderr $ readProcess "ghc-pkg" opts "" + (rv,output,err) <- readProcessWithExitCode "ghc-pkg" opts "" + case rv of + ExitFailure val -> do + hPutStrLn stderr err + fail $ "ghc-pkg " ++ intercalate " " opts ++ " (exit " ++ show val ++ ")" + ExitSuccess -> return () + return $ parseGhcPkgOutput $ lines output where opts = ["list", "-v"] ++ ghcPkgDbStackOpts dbs