From 6e222ce2252637da77a8d7ab460af4f0ce0841c1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 24 Aug 2013 12:54:39 -0700 Subject: Improved error reporting on filters. Avoid showing spurious output and avoid double error messages. --- pandoc.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pandoc.hs') diff --git a/pandoc.hs b/pandoc.hs index a16ffbc3c..8eed67544 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -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 -- cgit v1.2.3