aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src
diff options
context:
space:
mode:
authorMarcin Szamotulski <coot@coot.me>2022-05-24 08:29:59 +0200
committerGitHub <noreply@github.com>2022-05-24 08:29:59 +0200
commit041385bc43f0b99d26077787eb8ed9e394766438 (patch)
tree84d49d3be0eeb2b1a2c1ec487fe783d89cb6b6b2 /haddock-api/src
parentc0f06d55bd64d2777588860917be3dcdaede3479 (diff)
Check if doc-index.json exists before reading it (#1488)
Diffstat (limited to 'haddock-api/src')
-rw-r--r--haddock-api/src/Haddock/Backends/Xhtml.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index b7674b24..55783c67 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -418,11 +418,16 @@ ppJsonIndex odir maybe_source_url maybe_wiki_url unicode pkg qual_opt ifaces ins
(errors, installedIndexes) <-
partitionEithers
<$> traverse
- (\ifaceFile ->
+ (\ifaceFile -> do
let indexFile = takeDirectory ifaceFile
- FilePath.</> "doc-index.json" in
- bimap (indexFile,) (map (fixLink ifaceFile))
- <$> eitherDecodeFile @[JsonIndexEntry] indexFile)
+ FilePath.</> "doc-index.json"
+ a <- doesFileExist indexFile
+ if a then
+ bimap (indexFile,) (map (fixLink ifaceFile))
+ <$> eitherDecodeFile @[JsonIndexEntry] indexFile
+ else
+ return (Right [])
+ )
installedIfacesPaths
traverse_ (\(indexFile, err) -> putStrLn $ "haddock: Coudn't parse " ++ indexFile ++ ": " ++ err)
errors