git.iko.soy/typeable/pandoc
on master help sign in
Error: Added PandocFilterError.
d722d93John MacFarlane
src/Text/Pandoc/App.hs+4−8
@@ -493,21 +493,17 @@ externalFilter f args' d = liftIO $ do
493 unless (exists && isExecutable) $ do
493 unless (exists && isExecutable) $ do
494 mbExe <- findExecutable f'
494 mbExe <- findExecutable f'
495 when (isNothing mbExe) $
495 when (isNothing mbExe) $
496− E.throwIO $ PandocAppError 83 $
497− "Error running filter " ++ f ++ ":\n" ++
498− "Could not find executable '" ++ f' ++ "'."
496+ E.throwIO $ PandocFilterError f ("Could not find executable " ++ f')
499 env <- getEnvironment
497 env <- getEnvironment
500 let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
498 let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
501 (exitcode, outbs) <- E.handle filterException $
499 (exitcode, outbs) <- E.handle filterException $
502 pipeProcess env' f' args'' $ encode d
500 pipeProcess env' f' args'' $ encode d
503 case exitcode of
501 case exitcode of
504 ExitSuccess -> return $ either error id $ eitherDecode' outbs
502 ExitSuccess -> return $ either error id $ eitherDecode' outbs
505− ExitFailure ec -> E.throwIO $ PandocAppError 83 $
503+ ExitFailure ec -> E.throwIO $ PandocFilterError f
506− "Error running filter " ++ f ++ "\n" ++
507− "Filter returned error status " ++ show ec
504+ ("Filter returned error status " ++ show ec)
508 where filterException :: E.SomeException -> IO a
505 where filterException :: E.SomeException -> IO a
509− filterException e = E.throwIO $ PandocAppError 83 $
506+ filterException e = E.throwIO $ PandocFilterError f (show e)
510− "Error running filter " ++ f ++ "\n" ++ show e
511
507
512-- | Data structure for command line options.
508-- | Data structure for command line options.
513data Opt = Opt
509data Opt = Opt
src/Text/Pandoc/Error.hs+3
@@ -56,6 +56,7 @@ data PandocError = PandocIOError String IOError
56 | PandocFailOnWarningError
56 | PandocFailOnWarningError
57 | PandocPDFProgramNotFoundError String
57 | PandocPDFProgramNotFoundError String
58 | PandocPDFError String
58 | PandocPDFError String
59+ | PandocFilterError String String
59 | PandocAppError Int String
60 | PandocAppError Int String
60 deriving (Show, Typeable, Generic)
61 deriving (Show, Typeable, Generic)
61
62
@@ -88,6 +89,8 @@ handleError (Left e) =
88 PandocPDFProgramNotFoundError pdfprog -> err 47 $
89 PandocPDFProgramNotFoundError pdfprog -> err 47 $
89 pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
90 pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
90 PandocPDFError log -> err 43 $ "Error producing PDF.\n" ++ log
91 PandocPDFError log -> err 43 $ "Error producing PDF.\n" ++ log
92+ PandocFilterError filter msg -> err 83 $ "Error running filter " ++
93+ filter ++ ":\n" ++ msg
91 PandocAppError ec s -> err ec s
94 PandocAppError ec s -> err ec s
92
95
93err :: Int -> String -> IO a
96err :: Int -> String -> IO a