diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-08-24 12:54:39 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-08-24 12:54:39 -0700 |
commit | 6e222ce2252637da77a8d7ab460af4f0ce0841c1 (patch) | |
tree | 332fc3e67048493f9036be9a4bd8898b03cb7cb5 | |
parent | f7c14eddd81dfb89111b482cf49289d9d0135cc2 (diff) | |
download | pandoc-6e222ce2252637da77a8d7ab460af4f0ce0841c1.tar.gz |
Improved error reporting on filters.
Avoid showing spurious output and avoid double error messages.
-rw-r--r-- | pandoc.hs | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -91,14 +91,14 @@ isTextFormat :: String -> Bool isTextFormat s = takeWhile (`notElem` "+-") s `notElem` ["odt","docx","epub","epub3"] externalFilter :: FilePath -> [String] -> Pandoc -> IO Pandoc -externalFilter f args' d = E.handle filterException $ - do (exitcode, outbs, errbs) <- pipeProcess Nothing f args' $ encode d +externalFilter f args' d = do + (exitcode, outbs, errbs) <- E.handle filterException $ + pipeProcess Nothing f args' $ encode d when (not $ B.null errbs) $ B.hPutStr stderr errbs case exitcode of ExitSuccess -> return $ either error id $ eitherDecode' outbs - ExitFailure _ -> err 83 $ "Error running filter " ++ f ++ "\n" ++ - UTF8.toStringLazy outbs - where filterException :: E.SomeException -> IO Pandoc + ExitFailure _ -> err 83 $ "Error running filter " ++ f + where filterException :: E.SomeException -> IO a filterException e = err 83 $ "Error running filter " ++ f ++ "\n" ++ show e |