aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-01-20 19:52:56 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-01-20 19:52:56 -0800
commitb4a6c023431fcb313f04afa4c0d222c977c6d27c (patch)
treeed5fde68d6af943a904ea257f85706f989650c39 /src
parentce3653e39d3e3a57748c4922189eb9610d568051 (diff)
downloadpandoc-b4a6c023431fcb313f04afa4c0d222c977c6d27c.tar.gz
PDF: Better error message.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/PDF.hs10
-rw-r--r--src/pandoc.hs3
2 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index defe70181..d547835b5 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -56,10 +56,11 @@ tex2pdf' :: FilePath -- ^ temp directory for output
-> IO (Either ByteString ByteString)
tex2pdf' tmpDir program source = do
(exit, log', mbPdf) <- runTeXProgram program 3 tmpDir source
+ let msg = "Error producing PDF from TeX source."
case (exit, mbPdf) of
- (ExitFailure _, _) -> return $ Left $ extractMsg log'
- (ExitSuccess, Nothing) -> return $ Left
- "tex2pdf: ExitSuccess but no PDF created!"
+ (ExitFailure _, _) -> return $ Left $
+ msg <> "\n" <> extractMsg log'
+ (ExitSuccess, Nothing) -> return $ Left msg
(ExitSuccess, Just pdf) -> return $ Right pdf
data TeXProgram = PDFLaTeX
@@ -70,6 +71,9 @@ data TeXProgram = PDFLaTeX
| PDFTeX
deriving (Show, Read)
+(<>) :: ByteString -> ByteString -> ByteString
+(<>) = B.append
+
-- parsing output
extractMsg :: ByteString -> ByteString
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 0eae9cdc2..506ed703d 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -975,10 +975,9 @@ main = do
do res <- tex2pdf PDFLaTeX $ writeLaTeX writerOptions doc2
case res of
Right pdf -> writeBinary pdf
- Left err' -> B.hPutStr stderr err' >> B.hPutStr stderr nl
+ Left err' -> B.hPutStr stderr err'
| otherwise -> error $ "Unknown writer: " ++ writerName'
where writeBinary = B.writeFile (encodeString outputFile)
- nl = B.singleton 10
Just r -> writerFn outputFile =<< postProcess result
where writerFn "-" = UTF8.putStr
writerFn f = UTF8.writeFile f