git.iko.soy/typeable/pandoc
on master help sign in
Improved error reporting on filters.

Avoid showing spurious output and avoid double error messages.

commit6e222ce2252637da77a8d7ab460af4f0ce0841c1 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 24 Aug 2013, 12:54 (13 years ago) parentf7c14ed
1 file changed+5−5
pandoc.hs+5−5
pandoc.hs+5−5
@@ -91,14 +91,14 @@ isTextFormat :: String -> Bool
9191isTextFormat s = takeWhile (`notElem` "+-") s `notElem` ["odt","docx","epub","epub3"]
9292
9393externalFilter :: FilePath -> [String] -> Pandoc -> IO Pandoc
94−externalFilter f args' d = E.handle filterException $
95− do (exitcode, outbs, errbs) <- pipeProcess Nothing f args' $ encode d
94+externalFilter f args' d = do
95+ (exitcode, outbs, errbs) <- E.handle filterException $
96+ pipeProcess Nothing f args' $ encode d
9697 when (not $ B.null errbs) $ B.hPutStr stderr errbs
9798 case exitcode of
9899 ExitSuccess -> return $ either error id $ eitherDecode' outbs
99− ExitFailure _ -> err 83 $ "Error running filter " ++ f ++ "\n" ++
100− UTF8.toStringLazy outbs
101− where filterException :: E.SomeException -> IO Pandoc
100+ ExitFailure _ -> err 83 $ "Error running filter " ++ f
101+ where filterException :: E.SomeException -> IO a
102102 filterException e = err 83 $ "Error running filter " ++ f ++
103103 "\n" ++ show e
104104