git.iko.soy/typeable/pandoc
on master help sign in
PDF: Better error message.
commitb4a6c023431fcb313f04afa4c0d222c977c6d27c authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 20 Jan 2012, 19:52 (15 years ago) parentce3653e
2 files changed+8−5
src/Text/Pandoc/PDF.hs+7−3 src/pandoc.hs+1−2
src/Text/Pandoc/PDF.hs+7−3
@@ -56,10 +56,11 @@ tex2pdf' :: FilePath -- ^ temp directory for output
5656 -> IO (Either ByteString ByteString)
5757tex2pdf' tmpDir program source = do
5858 (exit, log', mbPdf) <- runTeXProgram program 3 tmpDir source
59+ let msg = "Error producing PDF from TeX source."
5960 case (exit, mbPdf) of
60− (ExitFailure _, _) -> return $ Left $ extractMsg log'
61− (ExitSuccess, Nothing) -> return $ Left
62− "tex2pdf: ExitSuccess but no PDF created!"
61+ (ExitFailure _, _) -> return $ Left $
62+ msg <> "\n" <> extractMsg log'
63+ (ExitSuccess, Nothing) -> return $ Left msg
6364 (ExitSuccess, Just pdf) -> return $ Right pdf
6465
6566data TeXProgram = PDFLaTeX
@@ -70,6 +71,9 @@ data TeXProgram = PDFLaTeX
7071 | PDFTeX
7172 deriving (Show, Read)
7273
74+(<>) :: ByteString -> ByteString -> ByteString
75+(<>) = B.append
76+
7377-- parsing output
7478
7579extractMsg :: ByteString -> ByteString
src/pandoc.hs+1−2
@@ -975,10 +975,9 @@ main = do
975975 do res <- tex2pdf PDFLaTeX $ writeLaTeX writerOptions doc2
976976 case res of
977977 Right pdf -> writeBinary pdf
978− Left err' -> B.hPutStr stderr err' >> B.hPutStr stderr nl
978+ Left err' -> B.hPutStr stderr err'
979979 | otherwise -> error $ "Unknown writer: " ++ writerName'
980980 where writeBinary = B.writeFile (encodeString outputFile)
981− nl = B.singleton 10
982981 Just r -> writerFn outputFile =<< postProcess result
983982 where writerFn "-" = UTF8.putStr
984983 writerFn f = UTF8.writeFile f