diff options
| author | Albert Krewinkel <[email protected]> | 2022-10-16 17:08:06 +0200 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2022-10-16 17:10:00 +0200 |
| commit | 246347722965c17fccfe368982fe55724566c69d (patch) | |
| tree | 63cb86e3aa6be094ba48a172a1665158690b1dec /pandoc-lua-engine/src | |
| parent | 726c54de27f42d050519c191a2f32bcdfc17c6a7 (diff) | |
Lua: fix peeker for PandocError.
String error messages were incorrectly popped of the stack when
retrieving a PandocError.
Diffstat (limited to 'pandoc-lua-engine/src')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs | 4 | ||||
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs | 4 |
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. |
