diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-05-27 15:43:50 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-05-27 15:43:50 -0400 |
commit | 53414931906dd5307f16601566cf8e860f7ebe2a (patch) | |
tree | 1de4b71b4f7f288071a0f6ae7ee5c91d5d1ac4c4 /Utility/ExternalSHA.hs | |
parent | 7bb9556f80b38d0294ef99d561bf789a4f6bc6f9 (diff) |
improve error message when checksum command exits nonzero
Diffstat (limited to 'Utility/ExternalSHA.hs')
-rw-r--r-- | Utility/ExternalSHA.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Utility/ExternalSHA.hs b/Utility/ExternalSHA.hs index 0defbaa16..3238c4733 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 } |