summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-04-13 19:24:50 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-15 11:53:45 +0200
commitd722d93b6118bfed4e0a176a66f859b9636ae689 (patch)
tree47a76eeec866f9650601250c519edbc03ead7ec1 /src
parent306dc624d982663e07d91bef6d2f84d311b978af (diff)
Error: Added PandocFilterError.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App.hs12
-rw-r--r--src/Text/Pandoc/Error.hs3
2 files changed, 7 insertions, 8 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index b34980c71..77e13a297 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -493,21 +493,17 @@ externalFilter f args' d = liftIO $ do
unless (exists && isExecutable) $ do
mbExe <- findExecutable f'
when (isNothing mbExe) $
- E.throwIO $ PandocAppError 83 $
- "Error running filter " ++ f ++ ":\n" ++
- "Could not find executable '" ++ f' ++ "'."
+ E.throwIO $ PandocFilterError f ("Could not find executable " ++ f')
env <- getEnvironment
let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
(exitcode, outbs) <- E.handle filterException $
pipeProcess env' f' args'' $ encode d
case exitcode of
ExitSuccess -> return $ either error id $ eitherDecode' outbs
- ExitFailure ec -> E.throwIO $ PandocAppError 83 $
- "Error running filter " ++ f ++ "\n" ++
- "Filter returned error status " ++ show ec
+ ExitFailure ec -> E.throwIO $ PandocFilterError f
+ ("Filter returned error status " ++ show ec)
where filterException :: E.SomeException -> IO a
- filterException e = E.throwIO $ PandocAppError 83 $
- "Error running filter " ++ f ++ "\n" ++ show e
+ filterException e = E.throwIO $ PandocFilterError f (show e)
-- | Data structure for command line options.
data Opt = Opt
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index b6782036f..4ead6aba8 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -56,6 +56,7 @@ data PandocError = PandocIOError String IOError
| PandocFailOnWarningError
| PandocPDFProgramNotFoundError String
| PandocPDFError String
+ | PandocFilterError String String
| PandocAppError Int String
deriving (Show, Typeable, Generic)
@@ -88,6 +89,8 @@ handleError (Left e) =
PandocPDFProgramNotFoundError pdfprog -> err 47 $
pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
PandocPDFError log -> err 43 $ "Error producing PDF.\n" ++ log
+ PandocFilterError filter msg -> err 83 $ "Error running filter " ++
+ filter ++ ":\n" ++ msg
PandocAppError ec s -> err ec s
err :: Int -> String -> IO a