mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Lua: fix peeker for PandocError.
String error messages were incorrectly popped of the stack when retrieving a PandocError.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user