aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'pandoc-lua-engine/src')
-rw-r--r--pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs4
-rw-r--r--pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs4
2 files changed, 5 insertions, 3 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs
index 7feba2d45..0e0e00dbd 100644
--- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs
+++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs
@@ -46,5 +46,7 @@ peekPandocError idx = Lua.retrieving "PandocError" $
liftLua (Lua.ltype idx) >>= \case
Lua.TypeUserdata -> peekUD typePandocError idx
_ -> do
- msg <- liftLua $ Lua.state >>= \l -> Lua.liftIO (Lua.popErrorMessage l)
+ msg <- liftLua $ do
+ Lua.pushvalue idx
+ Lua.state >>= \l -> Lua.liftIO (Lua.popErrorMessage l)
return $ PandocLuaError (UTF8.toText msg)
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs
index d922dfe1c..64f4bd1b4 100644
--- a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs
+++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs
@@ -88,9 +88,9 @@ instance PandocMonad PandocLua where
-- | Retrieve a @'PandocError'@ from the Lua stack.
popPandocError :: LuaE PandocError PandocError
popPandocError = do
- errResult <- runPeek $ peekPandocError top
+ errResult <- runPeek $ peekPandocError top `lastly` pop 1
case resultToEither errResult of
- Right x -> return x
+ Right x -> return x
Left err -> return $ PandocLuaError (T.pack err)
-- | Conversions between Lua errors and 'PandocError' exceptions.