From 041385bc43f0b99d26077787eb8ed9e394766438 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 24 May 2022 08:29:59 +0200 Subject: Check if doc-index.json exists before reading it (#1488) --- haddock-api/src/Haddock/Backends/Xhtml.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'haddock-api/src') 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 -- cgit v1.2.3