Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
Use top-level error GMEMissingHaddock when missing haddock html.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlohamalainen committed Jul 19, 2016
1 parent fb1c146 commit fa1417a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Language/Haskell/GhcMod/ImportedFrom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ guessHaddockUrl
-> FilePath
-> (FilePath -> [String] -> String -> IO String)
-> [GhcPkgDb]
-> m (Either String String)
-> m String
guessHaddockUrl modSum targetFile targetModule symbol lineNr colNr ghcPkg readProc pkgDbStack = do
gmLog GmDebug "guessHaddockUrl" $ strDoc $ "targetFile: " ++ targetFile
gmLog GmDebug "guessHaddockUrl" $ strDoc $ "targetModule: " ++ targetModule
Expand Down Expand Up @@ -734,9 +734,9 @@ guessHaddockUrl modSum targetFile targetModule symbol lineNr colNr ghcPkg readPr

e <- liftIO $ doesFileExist f

if e then return $ Right $ "file://" ++ f
if e then return $ "file://" ++ f
else do gmErrStrLn "Please reinstall packages using the flag '--enable-documentation' for 'cabal install.\n"
return $ Left $ "Could not find " ++ f
throw $ GMEMissingHaddock f

where
-- Convert a module name string, e.g. @Data.List@ to @Data-List.html@.
Expand Down Expand Up @@ -774,10 +774,7 @@ importedFrom file lineNr colNr (Expression symbol) = do
let modstr = moduleNameString $ ms_mod_name modSum :: String

res <- guessHaddockUrl modSum file modstr symbol lineNr colNr ghcPkg readProc pkgDbStack

case res of Right x -> return $ x ++ "\n"
Left err -> do gmErrStrLn $ show err ++ "\n"
liftIO exitFailure
return $ res ++ "\n"
where
handler (SomeException ex) = do
gmLog GmException "imported-from" $ showDoc ex
Expand Down
3 changes: 3 additions & 0 deletions Language/Haskell/GhcMod/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ data GhcModError
| GMETooManyCabalFiles [FilePath]
-- ^ Too many cabal files found.

| GMEMissingHaddock FilePath
-- ^ Haddock HTML file missing.

deriving (Eq,Show,Typeable)

instance Error GhcModError where
Expand Down

0 comments on commit fa1417a

Please sign in to comment.