From 7cb16b9efbf3010973f51f6cef66d75aa7e130e7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 May 2015 15:43:50 -0400 Subject: [PATCH] improve error message when checksum command exits nonzero --- Utility/ExternalSHA.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Utility/ExternalSHA.hs b/Utility/ExternalSHA.hs index 0defbaa16f..3238c47331 100644 --- a/Utility/ExternalSHA.hs +++ b/Utility/ExternalSHA.hs @@ -26,16 +26,16 @@ import Prelude externalSHA :: String -> Int -> FilePath -> IO (Either String String) externalSHA command shasize file = do - ls <- lines <$> catchDefaultIO "" (readsha (toCommand [File file])) - return $ sanitycheck =<< parse ls + v <- tryNonAsync $ readsha $ toCommand [File file] + return $ case v of + Right s -> sanitycheck =<< parse (lines s) + Left _ -> Left (command ++ " failed") where - {- sha commands output the filename, so need to set fileEncoding -} - readsha args = - withHandle StdoutHandle (createProcessChecked checkSuccessProcess) p $ \h -> do - fileEncoding h - output <- hGetContentsStrict h - hClose h - return output + readsha args = withHandle StdoutHandle createProcessSuccess p $ \h -> do + fileEncoding h + output <- hGetContentsStrict h + hClose h + return output where p = (proc command args) { std_out = CreatePipe }