git.iko.soy/typeable/pandoc
on master help sign in
Error: Added PandocFilterError.
commitd722d93b6118bfed4e0a176a66f859b9636ae689 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 13 Apr 2017, 19:24 (10 years ago) parent306dc62
2 files changed+7−8
src/Text/Pandoc/App.hs+4−8 src/Text/Pandoc/Error.hs+3
src/Text/Pandoc/App.hs+4−8
@@ -493,21 +493,17 @@ externalFilter f args' d = liftIO $ do
493493 unless (exists && isExecutable) $ do
494494 mbExe <- findExecutable f'
495495 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')
499497 env <- getEnvironment
500498 let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
501499 (exitcode, outbs) <- E.handle filterException $
502500 pipeProcess env' f' args'' $ encode d
503501 case exitcode of
504502 ExitSuccess -> return $ either error id $ eitherDecode' outbs
505− ExitFailure ec -> E.throwIO $ PandocAppError 83 $
506− "Error running filter " ++ f ++ "\n" ++
507− "Filter returned error status " ++ show ec
503+ ExitFailure ec -> E.throwIO $ PandocFilterError f
504+ ("Filter returned error status " ++ show ec)
508505 where filterException :: E.SomeException -> IO a
509− filterException e = E.throwIO $ PandocAppError 83 $
510− "Error running filter " ++ f ++ "\n" ++ show e
506+ filterException e = E.throwIO $ PandocFilterError f (show e)
511507
512508-- | Data structure for command line options.
513509data Opt = Opt
src/Text/Pandoc/Error.hs+3
@@ -56,6 +56,7 @@ data PandocError = PandocIOError String IOError
5656 | PandocFailOnWarningError
5757 | PandocPDFProgramNotFoundError String
5858 | PandocPDFError String
59+ | PandocFilterError String String
5960 | PandocAppError Int String
6061 deriving (Show, Typeable, Generic)
6162
@@ -88,6 +89,8 @@ handleError (Left e) =
8889 PandocPDFProgramNotFoundError pdfprog -> err 47 $
8990 pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."
9091 PandocPDFError log -> err 43 $ "Error producing PDF.\n" ++ log
92+ PandocFilterError filter msg -> err 83 $ "Error running filter " ++
93+ filter ++ ":\n" ++ msg
9194 PandocAppError ec s -> err ec s
9295
9396err :: Int -> String -> IO a