improve error message when checksum command exits nonzero
This commit is contained in:
parent
eddb9daa69
commit
7cb16b9efb
1 changed files with 9 additions and 9 deletions
|
@ -26,16 +26,16 @@ import Prelude
|
||||||
|
|
||||||
externalSHA :: String -> Int -> FilePath -> IO (Either String String)
|
externalSHA :: String -> Int -> FilePath -> IO (Either String String)
|
||||||
externalSHA command shasize file = do
|
externalSHA command shasize file = do
|
||||||
ls <- lines <$> catchDefaultIO "" (readsha (toCommand [File file]))
|
v <- tryNonAsync $ readsha $ toCommand [File file]
|
||||||
return $ sanitycheck =<< parse ls
|
return $ case v of
|
||||||
|
Right s -> sanitycheck =<< parse (lines s)
|
||||||
|
Left _ -> Left (command ++ " failed")
|
||||||
where
|
where
|
||||||
{- sha commands output the filename, so need to set fileEncoding -}
|
readsha args = withHandle StdoutHandle createProcessSuccess p $ \h -> do
|
||||||
readsha args =
|
fileEncoding h
|
||||||
withHandle StdoutHandle (createProcessChecked checkSuccessProcess) p $ \h -> do
|
output <- hGetContentsStrict h
|
||||||
fileEncoding h
|
hClose h
|
||||||
output <- hGetContentsStrict h
|
return output
|
||||||
hClose h
|
|
||||||
return output
|
|
||||||
where
|
where
|
||||||
p = (proc command args) { std_out = CreatePipe }
|
p = (proc command args) { std_out = CreatePipe }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue