From 2d3813e0dd7c2752bf299eb39e0b226d911920f1 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 23 Oct 2021 12:55:33 +0200 Subject: Lua: convert IOErrors to PandocErrors in pandoc.pipe function Fixes: #7523 --- src/Text/Pandoc/Lua/Module/Pandoc.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Text/Pandoc/Lua/Module/Pandoc.hs b/src/Text/Pandoc/Lua/Module/Pandoc.hs index ef1d6f078..eeadfa340 100644 --- a/src/Text/Pandoc/Lua/Module/Pandoc.hs +++ b/src/Text/Pandoc/Lua/Module/Pandoc.hs @@ -18,6 +18,7 @@ module Text.Pandoc.Lua.Module.Pandoc import Prelude hiding (read) import Control.Applicative (optional) import Control.Monad ((>=>), forM_, when) +import Control.Monad.Catch (catch, throwM) import Control.Monad.Except (throwError) import Data.Default (Default (..)) import Data.Maybe (fromMaybe) @@ -206,6 +207,7 @@ pipe :: String -- ^ path to executable -> PandocLua NumResults pipe command args input = liftPandocLua $ do (ec, output) <- Lua.liftIO $ pipeProcess Nothing command args input + `catch` (throwM . PandocIOError "pipe") case ec of ExitSuccess -> 1 <$ Lua.push output ExitFailure n -> do -- cgit v1.2.3