aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2020-05-03 01:12:42 +0200
committerGitHub <noreply@github.com>2020-05-02 16:12:42 -0700
commit0fafe9dd32d5a0266d74ac78b1818050bc69a4bd (patch)
treec8f766739cd3289504336f40dd5e6529965b6298
parent9e7572da1fcc5f7299e92c93f8960e8705d184db (diff)
downloadpandoc-0fafe9dd32d5a0266d74ac78b1818050bc69a4bd.tar.gz
Lua filters: improve error messages for failing filters (#6332)
Print the Lua error properly instead of displaying their `show` string.
-rw-r--r--src/Text/Pandoc/Filter/Lua.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Filter/Lua.hs b/src/Text/Pandoc/Filter/Lua.hs
index 8df057bfa..a76c8da2f 100644
--- a/src/Text/Pandoc/Filter/Lua.hs
+++ b/src/Text/Pandoc/Filter/Lua.hs
@@ -16,7 +16,7 @@ import Control.Monad ((>=>))
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.Error (PandocError (PandocFilterError, PandocLuaError))
import Text.Pandoc.Lua (Global (..), runLua, runFilterFile, setGlobals)
import Text.Pandoc.Options (ReaderOptions)
@@ -42,4 +42,6 @@ apply ropts args fp doc = do
forceResult :: FilePath -> Either PandocError Pandoc -> PandocIO Pandoc
forceResult fp eitherResult = case eitherResult of
Right x -> return x
- Left err -> throw (PandocFilterError (T.pack fp) (T.pack $ show err))
+ Left err -> throw . PandocFilterError (T.pack fp) $ case err of
+ PandocLuaError msg -> msg
+ _ -> T.pack $ show err