diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2020-04-17 18:02:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 18:02:25 -0700 |
| commit | 0d2b8e3fe1d6a27aac082be7711b7156783b3051 (patch) | |
| tree | 459122371d6b88a7756eee954b81f2bba4bdfdca /src/Text/Pandoc/Filter | |
| parent | 8f40b4ba14fce10199a059a281c9bd10c884241d (diff) | |
| parent | 62cf21cbaa9ac3fbc2ba7218a3037208364c80a4 (diff) | |
| download | pandoc-0d2b8e3fe1d6a27aac082be7711b7156783b3051.tar.gz | |
Merge pull request #6211 from tarleb/lua-pandocerror
API change: create PandocLua type, use PandocError for exceptions
Diffstat (limited to 'src/Text/Pandoc/Filter')
| -rw-r--r-- | src/Text/Pandoc/Filter/JSON.hs | 6 | ||||
| -rw-r--r-- | src/Text/Pandoc/Filter/Lua.hs | 9 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Filter/JSON.hs b/src/Text/Pandoc/Filter/JSON.hs index 7e27f7d94..83ec9a97c 100644 --- a/src/Text/Pandoc/Filter/JSON.hs +++ b/src/Text/Pandoc/Filter/JSON.hs @@ -23,7 +23,6 @@ import System.Directory (executable, doesFileExist, findExecutable, import System.Environment (getEnvironment) import System.Exit (ExitCode (..)) import System.FilePath ((</>), takeExtension) -import Text.Pandoc.Class.PandocIO (PandocIO) import Text.Pandoc.Error (PandocError (PandocFilterError)) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Options (ReaderOptions) @@ -32,11 +31,12 @@ import Text.Pandoc.Shared (pandocVersion, tshow) import qualified Control.Exception as E import qualified Text.Pandoc.UTF8 as UTF8 -apply :: ReaderOptions +apply :: MonadIO m + => ReaderOptions -> [String] -> FilePath -> Pandoc - -> PandocIO Pandoc + -> m Pandoc apply ropts args f = liftIO . externalFilter ropts f args externalFilter :: MonadIO m diff --git a/src/Text/Pandoc/Filter/Lua.hs b/src/Text/Pandoc/Filter/Lua.hs index a50e5217d..8df057bfa 100644 --- a/src/Text/Pandoc/Filter/Lua.hs +++ b/src/Text/Pandoc/Filter/Lua.hs @@ -17,8 +17,7 @@ import qualified Data.Text as T import Text.Pandoc.Class.PandocIO (PandocIO) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocFilterError)) -import Text.Pandoc.Lua (Global (..), LuaException (..), - runLua, runFilterFile, setGlobals) +import Text.Pandoc.Lua (Global (..), runLua, runFilterFile, setGlobals) import Text.Pandoc.Options (ReaderOptions) -- | Run the Lua filter in @filterPath@ for a transformation to the @@ -40,7 +39,7 @@ apply ropts args fp doc = do ] runFilterFile fp doc -forceResult :: FilePath -> Either LuaException Pandoc -> PandocIO Pandoc +forceResult :: FilePath -> Either PandocError Pandoc -> PandocIO Pandoc forceResult fp eitherResult = case eitherResult of - Right x -> return x - Left (LuaException s) -> throw (PandocFilterError (T.pack fp) s) + Right x -> return x + Left err -> throw (PandocFilterError (T.pack fp) (T.pack $ show err)) |
