From c5910fd179d374f644ab3c843b243a51a7df9b24 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 19 Apr 2015 00:38:29 -0400 Subject: removed all uses of undefined from code base It's a code smell, can lead to hard to diagnose error messages. --- Remote/GCrypt.hs | 2 +- Remote/Git.hs | 7 ++++--- Remote/Helper/Chunked.hs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Remote') diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs index c27519825..01efc6060 100644 --- a/Remote/GCrypt.hs +++ b/Remote/GCrypt.hs @@ -397,7 +397,7 @@ getGCryptId fast r gc | Git.repoIsLocal r || Git.repoIsLocalUnknown r = extract <$> liftIO (catchMaybeIO $ Git.Config.read r) | not fast = extract . liftM fst <$> getM (eitherToMaybe <$>) - [ Ssh.onRemote r (Git.Config.fromPipe r, return (Left undefined)) "configlist" [] [] + [ Ssh.onRemote r (Git.Config.fromPipe r, return (Left $ error "configlist failed")) "configlist" [] [] , getConfigViaRsync r gc ] | otherwise = return (Nothing, r) diff --git a/Remote/Git.hs b/Remote/Git.hs index fdd0049ca..4804cb10e 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -199,7 +199,7 @@ tryGitConfigRead :: Git.Repo -> Annex Git.Repo tryGitConfigRead r | haveconfig r = return r -- already read | Git.repoIsSsh r = store $ do - v <- Ssh.onRemote r (pipedconfig, return (Left undefined)) "configlist" [] [] + v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] [] case v of Right r' | haveconfig r' -> return r' @@ -228,9 +228,10 @@ tryGitConfigRead r uo <- Url.getUrlOptions v <- liftIO $ withTmpFile "git-annex.tmp" $ \tmpfile h -> do hClose h - ifM (Url.downloadQuiet (Git.repoLocation r ++ "/config") tmpfile uo) + let url = Git.repoLocation r ++ "/config" + ifM (Url.downloadQuiet url tmpfile uo) ( pipedconfig "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile] - , return $ Left undefined + , return $ Left $ error $ "unable to load config from " ++ url ) case v of Left _ -> do diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs index 2f21ba66c..23ed3dbf8 100644 --- a/Remote/Helper/Chunked.hs +++ b/Remote/Helper/Chunked.hs @@ -72,7 +72,7 @@ chunkKeyStream basek chunksize = ChunkKeyStream $ map mk [1..] nextChunkKeyStream :: ChunkKeyStream -> (Key, ChunkKeyStream) nextChunkKeyStream (ChunkKeyStream (k:l)) = (k, ChunkKeyStream l) -nextChunkKeyStream (ChunkKeyStream []) = undefined -- stream is infinite! +nextChunkKeyStream (ChunkKeyStream []) = error "expected infinite ChunkKeyStream" takeChunkKeyStream :: ChunkCount -> ChunkKeyStream -> [Key] takeChunkKeyStream n (ChunkKeyStream l) = genericTake n l -- cgit v1.2.3