git.iko.soy/typeable/pandoc
on master help sign in
Lua filters: improve error messages for failing filters (#6332)

Print the Lua error properly instead of displaying their `show` string.

commit0fafe9dd32d5a0266d74ac78b1818050bc69a4bd authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 3 May 2020, 01:12 (6 years ago) parent9e7572d
1 file changed+4−2
src/Text/Pandoc/Filter/Lua.hs+4−2
src/Text/Pandoc/Filter/Lua.hs+4−2
@@ -16,7 +16,7 @@ import Control.Monad ((>=>))
1616import qualified Data.Text as T
1717import Text.Pandoc.Class.PandocIO (PandocIO)
1818import Text.Pandoc.Definition (Pandoc)
19−import Text.Pandoc.Error (PandocError (PandocFilterError))
19+import Text.Pandoc.Error (PandocError (PandocFilterError, PandocLuaError))
2020import Text.Pandoc.Lua (Global (..), runLua, runFilterFile, setGlobals)
2121import Text.Pandoc.Options (ReaderOptions)
2222
@@ -42,4 +42,6 @@ apply ropts args fp doc = do
4242forceResult :: FilePath -> Either PandocError Pandoc -> PandocIO Pandoc
4343forceResult fp eitherResult = case eitherResult of
4444 Right x -> return x
45− Left err -> throw (PandocFilterError (T.pack fp) (T.pack $ show err))
45+ Left err -> throw . PandocFilterError (T.pack fp) $ case err of
46+ PandocLuaError msg -> msg
47+ _ -> T.pack $ show err