error
-> throw $ GMEProcess
This commit is contained in:
parent
4aa75818d8
commit
899d583549
@ -126,12 +126,12 @@ gmeDoc e = case e of
|
|||||||
compsDoc sc = fsep $ punctuate comma $
|
compsDoc sc = fsep $ punctuate comma $
|
||||||
map gmComponentNameDoc $ Set.toList sc
|
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
|
case emsg of
|
||||||
Right err ->
|
Right err ->
|
||||||
text (printf "Launching system command `%s` failed: " c)
|
text (printf "Launching system command `%s` failed: " c)
|
||||||
<> gmeDoc err
|
<> gmeDoc err
|
||||||
Left (_out, _err, rv) -> text $
|
Left rv -> text $
|
||||||
printf "Launching system command `%s` failed (exited with %d)" c rv
|
printf "Launching system command `%s` failed (exited with %d)" c rv
|
||||||
GMENoCabalFile ->
|
GMENoCabalFile ->
|
||||||
text "No cabal file found."
|
text "No cabal file found."
|
||||||
|
@ -188,7 +188,7 @@ readProcessStderrChan' pute = go pute
|
|||||||
res <- waitForProcess h
|
res <- waitForProcess h
|
||||||
case res of
|
case res of
|
||||||
ExitFailure rv ->
|
ExitFailure rv ->
|
||||||
processFailedException "readProcessStderrChan" exe args rv
|
throw $ GMEProcess "readProcessStderrChan" exe args $ Left rv
|
||||||
ExitSuccess ->
|
ExitSuccess ->
|
||||||
return output
|
return output
|
||||||
where
|
where
|
||||||
@ -204,9 +204,3 @@ withForkWait async body = do
|
|||||||
tid <- forkIO $ try (restore async) >>= putMVar waitVar
|
tid <- forkIO $ try (restore async) >>= putMVar waitVar
|
||||||
let wait = takeMVar waitVar >>= either throwIO return
|
let wait = takeMVar waitVar >>= either throwIO return
|
||||||
restore (body wait) `onException` killThread tid
|
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 ++ ")"]
|
|
||||||
|
@ -35,7 +35,6 @@ import System.Process
|
|||||||
import System.Info.Extra
|
import System.Info.Extra
|
||||||
|
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
import Language.Haskell.GhcMod.Error
|
|
||||||
import Language.Haskell.GhcMod.Caching
|
import Language.Haskell.GhcMod.Caching
|
||||||
import Language.Haskell.GhcMod.Output
|
import Language.Haskell.GhcMod.Output
|
||||||
import qualified Language.Haskell.GhcMod.Utils as U
|
import qualified Language.Haskell.GhcMod.Utils as U
|
||||||
|
@ -372,9 +372,9 @@ data GhcModError
|
|||||||
| GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)]
|
| GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)]
|
||||||
-- ^ Could not find a consistent component assignment for modules
|
-- ^ 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
|
-- ^ Launching an operating system process failed. Fields in
|
||||||
-- order: command, arguments, (stdout, stderr, exitcode)
|
-- order: function, command, arguments, (stdout, stderr, exitcode)
|
||||||
|
|
||||||
| GMENoCabalFile
|
| GMENoCabalFile
|
||||||
-- ^ No cabal file found.
|
-- ^ No cabal file found.
|
||||||
|
@ -12,6 +12,7 @@ import System.Environment (getExecutablePath)
|
|||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import TestUtils
|
import TestUtils
|
||||||
|
import Prelude
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
|
Loading…
Reference in New Issue
Block a user