aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-04-13 17:02:30 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-15 11:53:45 +0200
commitd5701e625ceff494f4a54aa82490fe8e82dd1672 (patch)
treeedae1caa24bea5450e3fdb4fd3ab63bab292f6d2 /src/Text
parentdd4110fb09aa676cb03ed9cec52b21f9e7e46a3f (diff)
downloadpandoc-d5701e625ceff494f4a54aa82490fe8e82dd1672.tar.gz
Text.Pandoc.Error: added new constructors.
- PandocSyntaxMapError String - PandocFailOnWarningError - PandocPDFProgramNotFoundError String
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App.hs15
-rw-r--r--src/Text/Pandoc/Error.hs7
2 files changed, 13 insertions, 9 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 619c692a0..e44c6ebfb 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -181,7 +181,7 @@ convertWithOpts opts = do
"\nTo create a pdf using pandoc, use " ++
"-t latex|beamer|context|ms|html5" ++
"\nand specify an output file with " ++
- ".pdf extension (-o filename.pdf)." ++
+ ".pdf extension (-o filename.pdf)."
else e
Right w -> return (w :: Writer PandocIO)
@@ -304,7 +304,7 @@ convertWithOpts opts = do
let addSyntaxMap existingmap f = do
res <- parseSyntaxDefinition f
case res of
- Left errstr -> E.throwIO $ PandocAppError 67 errstr
+ Left errstr -> E.throwIO $ PandocSyntaxMapError errstr
Right syn -> return $ addSyntaxDefinition syn existingmap
syntaxMap <- foldM addSyntaxMap defaultSyntaxMap
@@ -312,7 +312,7 @@ convertWithOpts opts = do
case missingIncludes (M.elems syntaxMap) of
[] -> return ()
- xs -> E.throwIO $ PandocAppError 73 $
+ xs -> E.throwIO $ PandocSyntaxMapError $
"Missing syntax definitions:\n" ++
unlines (map
(\(syn,dep) -> (T.unpack syn ++ " requires " ++
@@ -388,8 +388,7 @@ convertWithOpts opts = do
Just logfile -> B.writeFile logfile (encodeLogMessages reports)
let isWarning msg = messageVerbosity msg == WARNING
when (optFailIfWarnings opts && any isWarning reports) $
- E.throwIO $
- PandocAppError 3 "Failing because there were warnings."
+ E.throwIO PandocFailOnWarningError
return res
let sourceToDoc :: [FilePath] -> PandocIO (Pandoc, MediaBag)
@@ -443,10 +442,8 @@ convertWithOpts opts = do
| otherwise -> optLaTeXEngine opts
-- check for pdf creating program
mbPdfProg <- liftIO $ findExecutable pdfprog
- when (isNothing mbPdfProg) $
- liftIO $ E.throwIO $ PandocAppError 41 $
- pdfprog ++ " not found. " ++
- pdfprog ++ " is needed for pdf output."
+ when (isNothing mbPdfProg) $ liftIO $ E.throwIO $
+ PandocPDFProgramNotFoundError pdfprog
res <- makePDF pdfprog f writerOptions verbosity media doc'
case res of
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index 454ad9982..36e9cca63 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -52,6 +52,9 @@ data PandocError = PandocIOError String IOError
| PandocParsecError Input ParseError
| PandocMakePDFError String
| PandocOptionError String
+ | PandocSyntaxMapError String
+ | PandocFailOnWarningError
+ | PandocPDFProgramNotFoundError String
| PandocAppError Int String
deriving (Show, Typeable, Generic)
@@ -79,6 +82,10 @@ handleError (Left e) =
in err 65 $ "\nError at " ++ show err' ++ errorInFile
PandocMakePDFError s -> err 65 s
PandocOptionError s -> err 2 s
+ PandocSyntaxMapError s -> err 67 s
+ PandocFailOnWarningError -> err 3 "Failing because there were warnings."
+ PandocPDFProgramNotFoundError pdfprog -> err 47 $
+ pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
PandocAppError ec s -> err ec s
err :: Int -> String -> IO a