Skip to content

Commit

Permalink
Better Hoogle error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuuzetsu committed Dec 24, 2013
1 parent 121e7d0 commit 711196b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions yi/src/library/Yi/Hoogle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ gv = filter f
-- | Query Hoogle, with given search and options. This errors out on no
-- results or if the hoogle command is not on path.
hoogleRaw :: String -> String -> IO [String]
hoogleRaw srch opts = do (status,out,_err) <- runProgCommand "hoogle" [opts, srch]
when (status == ExitFailure 1) $
fail "Error running hoogle command. Is hoogle on path?"
let results = lines out
if results == ["No results found"] then fail "No Hoogle results"
else return results
hoogleRaw srch opts = do
outp@(status,out,_err) <- runProgCommand "hoogle" [opts, srch]
case outp of
(ExitFailure 1, "", "") -> -- no output, probably failed to run binary
fail "Error running hoogle command. Is hoogle on path?"
(ExitFailure 1, xs, _) -> fail $ "hoogle failed with: " ++ xs
_ -> return ()
let results = lines out
if results == ["No results found"]
then fail "No Hoogle results"
else return results

-- | Filter the output of 'hoogleRaw' to leave just functions.
hoogleFunctions :: String -> IO [String]
Expand Down Expand Up @@ -61,4 +66,3 @@ hoogleSearch = do

-- The quotes help legibility between closely-packed results
withEditor $ printMsgs $ map show results

0 comments on commit 711196b

Please sign in to comment.