From 899d583549468a2be47f282a87a04f065b0d3686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Mon, 31 Aug 2015 08:55:49 +0200 Subject: [PATCH] `error` -> throw $ GMEProcess --- Language/Haskell/GhcMod/Error.hs | 4 ++-- Language/Haskell/GhcMod/Output.hs | 8 +------- Language/Haskell/GhcMod/PathsAndFiles.hs | 1 - Language/Haskell/GhcMod/Types.hs | 4 ++-- test/InfoSpec.hs | 1 + 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Language/Haskell/GhcMod/Error.hs b/Language/Haskell/GhcMod/Error.hs index 2bb3f4e..21f5892 100644 --- a/Language/Haskell/GhcMod/Error.hs +++ b/Language/Haskell/GhcMod/Error.hs @@ -126,12 +126,12 @@ gmeDoc e = case e of compsDoc sc = fsep $ punctuate comma $ map gmComponentNameDoc $ Set.toList sc - GMEProcess cmd args emsg -> let c = showCommandForUser cmd args in + GMEProcess _fn cmd args emsg -> let c = showCommandForUser cmd args in case emsg of Right err -> text (printf "Launching system command `%s` failed: " c) <> gmeDoc err - Left (_out, _err, rv) -> text $ + Left rv -> text $ printf "Launching system command `%s` failed (exited with %d)" c rv GMENoCabalFile -> text "No cabal file found." diff --git a/Language/Haskell/GhcMod/Output.hs b/Language/Haskell/GhcMod/Output.hs index 6115707..b51e8bb 100644 --- a/Language/Haskell/GhcMod/Output.hs +++ b/Language/Haskell/GhcMod/Output.hs @@ -188,7 +188,7 @@ readProcessStderrChan' pute = go pute res <- waitForProcess h case res of ExitFailure rv -> - processFailedException "readProcessStderrChan" exe args rv + throw $ GMEProcess "readProcessStderrChan" exe args $ Left rv ExitSuccess -> return output where @@ -204,9 +204,3 @@ withForkWait async body = do tid <- forkIO $ try (restore async) >>= putMVar waitVar let wait = takeMVar waitVar >>= either throwIO return restore (body wait) `onException` killThread tid - -processFailedException :: String -> String -> [String] -> Int -> IO a -processFailedException fn exe args rv = - error $ concat [ fn, ": ", exe, " " - , intercalate " " (map show args) - , " (exit " ++ show rv ++ ")"] diff --git a/Language/Haskell/GhcMod/PathsAndFiles.hs b/Language/Haskell/GhcMod/PathsAndFiles.hs index 42557f4..808c932 100644 --- a/Language/Haskell/GhcMod/PathsAndFiles.hs +++ b/Language/Haskell/GhcMod/PathsAndFiles.hs @@ -35,7 +35,6 @@ import System.Process import System.Info.Extra import Language.Haskell.GhcMod.Types -import Language.Haskell.GhcMod.Error import Language.Haskell.GhcMod.Caching import Language.Haskell.GhcMod.Output import qualified Language.Haskell.GhcMod.Utils as U diff --git a/Language/Haskell/GhcMod/Types.hs b/Language/Haskell/GhcMod/Types.hs index 135e157..8e95ceb 100644 --- a/Language/Haskell/GhcMod/Types.hs +++ b/Language/Haskell/GhcMod/Types.hs @@ -372,9 +372,9 @@ data GhcModError | GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)] -- ^ Could not find a consistent component assignment for modules - | GMEProcess String [String] (Either (String, String, Int) GhcModError) + | GMEProcess String String [String] (Either Int GhcModError) -- ^ Launching an operating system process failed. Fields in - -- order: command, arguments, (stdout, stderr, exitcode) + -- order: function, command, arguments, (stdout, stderr, exitcode) | GMENoCabalFile -- ^ No cabal file found. diff --git a/test/InfoSpec.hs b/test/InfoSpec.hs index 6a5296c..bd689a7 100644 --- a/test/InfoSpec.hs +++ b/test/InfoSpec.hs @@ -12,6 +12,7 @@ import System.Environment (getExecutablePath) import System.FilePath import Test.Hspec import TestUtils +import Prelude spec :: Spec spec = do