git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc.Error: added new constructors.
d5701e6John MacFarlane
src/Text/Pandoc/App.hs+6−9
@@ -181,7 +181,7 @@ convertWithOpts opts = do
181 "\nTo create a pdf using pandoc, use " ++
181 "\nTo create a pdf using pandoc, use " ++
182 "-t latex|beamer|context|ms|html5" ++
182 "-t latex|beamer|context|ms|html5" ++
183 "\nand specify an output file with " ++
183 "\nand specify an output file with " ++
184− ".pdf extension (-o filename.pdf)." ++
184+ ".pdf extension (-o filename.pdf)."
185 else e
185 else e
186 Right w -> return (w :: Writer PandocIO)
186 Right w -> return (w :: Writer PandocIO)
187
187
@@ -304,7 +304,7 @@ convertWithOpts opts = do
304 let addSyntaxMap existingmap f = do
304 let addSyntaxMap existingmap f = do
305 res <- parseSyntaxDefinition f
305 res <- parseSyntaxDefinition f
306 case res of
306 case res of
307− Left errstr -> E.throwIO $ PandocAppError 67 errstr
307+ Left errstr -> E.throwIO $ PandocSyntaxMapError errstr
308 Right syn -> return $ addSyntaxDefinition syn existingmap
308 Right syn -> return $ addSyntaxDefinition syn existingmap
309
309
310 syntaxMap <- foldM addSyntaxMap defaultSyntaxMap
310 syntaxMap <- foldM addSyntaxMap defaultSyntaxMap
@@ -312,7 +312,7 @@ convertWithOpts opts = do
312
312
313 case missingIncludes (M.elems syntaxMap) of
313 case missingIncludes (M.elems syntaxMap) of
314 [] -> return ()
314 [] -> return ()
315− xs -> E.throwIO $ PandocAppError 73 $
315+ xs -> E.throwIO $ PandocSyntaxMapError $
316 "Missing syntax definitions:\n" ++
316 "Missing syntax definitions:\n" ++
317 unlines (map
317 unlines (map
318 (\(syn,dep) -> (T.unpack syn ++ " requires " ++
318 (\(syn,dep) -> (T.unpack syn ++ " requires " ++
@@ -388,8 +388,7 @@ convertWithOpts opts = do
388 Just logfile -> B.writeFile logfile (encodeLogMessages reports)
388 Just logfile -> B.writeFile logfile (encodeLogMessages reports)
389 let isWarning msg = messageVerbosity msg == WARNING
389 let isWarning msg = messageVerbosity msg == WARNING
390 when (optFailIfWarnings opts && any isWarning reports) $
390 when (optFailIfWarnings opts && any isWarning reports) $
391− E.throwIO $
391+ E.throwIO PandocFailOnWarningError
392− PandocAppError 3 "Failing because there were warnings."
393 return res
392 return res
394
393
395 let sourceToDoc :: [FilePath] -> PandocIO (Pandoc, MediaBag)
394 let sourceToDoc :: [FilePath] -> PandocIO (Pandoc, MediaBag)
@@ -443,10 +442,8 @@ convertWithOpts opts = do
443 | otherwise -> optLaTeXEngine opts
442 | otherwise -> optLaTeXEngine opts
444 -- check for pdf creating program
443 -- check for pdf creating program
445 mbPdfProg <- liftIO $ findExecutable pdfprog
444 mbPdfProg <- liftIO $ findExecutable pdfprog
446− when (isNothing mbPdfProg) $
445+ when (isNothing mbPdfProg) $ liftIO $ E.throwIO $
447− liftIO $ E.throwIO $ PandocAppError 41 $
446+ PandocPDFProgramNotFoundError pdfprog
448− pdfprog ++ " not found. " ++
449− pdfprog ++ " is needed for pdf output."
450
447
451 res <- makePDF pdfprog f writerOptions verbosity media doc'
448 res <- makePDF pdfprog f writerOptions verbosity media doc'
452 case res of
449 case res of
src/Text/Pandoc/Error.hs+7
@@ -52,6 +52,9 @@ data PandocError = PandocIOError String IOError
52 | PandocParsecError Input ParseError
52 | PandocParsecError Input ParseError
53 | PandocMakePDFError String
53 | PandocMakePDFError String
54 | PandocOptionError String
54 | PandocOptionError String
55+ | PandocSyntaxMapError String
56+ | PandocFailOnWarningError
57+ | PandocPDFProgramNotFoundError String
55 | PandocAppError Int String
58 | PandocAppError Int String
56 deriving (Show, Typeable, Generic)
59 deriving (Show, Typeable, Generic)
57
60
@@ -79,6 +82,10 @@ handleError (Left e) =
79 in err 65 $ "\nError at " ++ show err' ++ errorInFile
82 in err 65 $ "\nError at " ++ show err' ++ errorInFile
80 PandocMakePDFError s -> err 65 s
83 PandocMakePDFError s -> err 65 s
81 PandocOptionError s -> err 2 s
84 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."
82 PandocAppError ec s -> err ec s
89 PandocAppError ec s -> err ec s
83
90
84err :: Int -> String -> IO a
91err :: Int -> String -> IO a