git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc.Error: added new constructors.

- PandocSyntaxMapError String - PandocFailOnWarningError - PandocPDFProgramNotFoundError String

commitd5701e625ceff494f4a54aa82490fe8e82dd1672 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 13 Apr 2017, 17:02 (10 years ago) parentdd4110f
2 files changed+13−9
src/Text/Pandoc/App.hs+6−9 src/Text/Pandoc/Error.hs+7
src/Text/Pandoc/App.hs+6−9
@@ -181,7 +181,7 @@ convertWithOpts opts = do
181181 "\nTo create a pdf using pandoc, use " ++
182182 "-t latex|beamer|context|ms|html5" ++
183183 "\nand specify an output file with " ++
184− ".pdf extension (-o filename.pdf)." ++
184+ ".pdf extension (-o filename.pdf)."
185185 else e
186186 Right w -> return (w :: Writer PandocIO)
187187
@@ -304,7 +304,7 @@ convertWithOpts opts = do
304304 let addSyntaxMap existingmap f = do
305305 res <- parseSyntaxDefinition f
306306 case res of
307− Left errstr -> E.throwIO $ PandocAppError 67 errstr
307+ Left errstr -> E.throwIO $ PandocSyntaxMapError errstr
308308 Right syn -> return $ addSyntaxDefinition syn existingmap
309309
310310 syntaxMap <- foldM addSyntaxMap defaultSyntaxMap
@@ -312,7 +312,7 @@ convertWithOpts opts = do
312312
313313 case missingIncludes (M.elems syntaxMap) of
314314 [] -> return ()
315− xs -> E.throwIO $ PandocAppError 73 $
315+ xs -> E.throwIO $ PandocSyntaxMapError $
316316 "Missing syntax definitions:\n" ++
317317 unlines (map
318318 (\(syn,dep) -> (T.unpack syn ++ " requires " ++
@@ -388,8 +388,7 @@ convertWithOpts opts = do
388388 Just logfile -> B.writeFile logfile (encodeLogMessages reports)
389389 let isWarning msg = messageVerbosity msg == WARNING
390390 when (optFailIfWarnings opts && any isWarning reports) $
391− E.throwIO $
392− PandocAppError 3 "Failing because there were warnings."
391+ E.throwIO PandocFailOnWarningError
393392 return res
394393
395394 let sourceToDoc :: [FilePath] -> PandocIO (Pandoc, MediaBag)
@@ -443,10 +442,8 @@ convertWithOpts opts = do
443442 | otherwise -> optLaTeXEngine opts
444443 -- check for pdf creating program
445444 mbPdfProg <- liftIO $ findExecutable pdfprog
446− when (isNothing mbPdfProg) $
447− liftIO $ E.throwIO $ PandocAppError 41 $
448− pdfprog ++ " not found. " ++
449− pdfprog ++ " is needed for pdf output."
445+ when (isNothing mbPdfProg) $ liftIO $ E.throwIO $
446+ PandocPDFProgramNotFoundError pdfprog
450447
451448 res <- makePDF pdfprog f writerOptions verbosity media doc'
452449 case res of
src/Text/Pandoc/Error.hs+7
@@ -52,6 +52,9 @@ data PandocError = PandocIOError String IOError
5252 | PandocParsecError Input ParseError
5353 | PandocMakePDFError String
5454 | PandocOptionError String
55+ | PandocSyntaxMapError String
56+ | PandocFailOnWarningError
57+ | PandocPDFProgramNotFoundError String
5558 | PandocAppError Int String
5659 deriving (Show, Typeable, Generic)
5760
@@ -79,6 +82,10 @@ handleError (Left e) =
7982 in err 65 $ "\nError at " ++ show err' ++ errorInFile
8083 PandocMakePDFError s -> err 65 s
8184 PandocOptionError s -> err 2 s
85+ PandocSyntaxMapError s -> err 67 s
86+ PandocFailOnWarningError -> err 3 "Failing because there were warnings."
87+ PandocPDFProgramNotFoundError pdfprog -> err 47 $
88+ pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
8289 PandocAppError ec s -> err ec s
8390
8491err :: Int -> String -> IO a