From af2b4c47bb1759ca7c41169987526ea0f53c973a Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 16 Oct 2022 21:36:53 +0200 Subject: [PATCH] Lua: fix rendering of Lua errors in Lua Otherwise the `Error running Lua` message can be prepended multiple times. --- pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 0e0e00dbd..c9721a53d 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs @@ -30,7 +30,9 @@ import qualified Text.Pandoc.UTF8 as UTF8 typePandocError :: LuaError e => DocumentedType e PandocError typePandocError = deftype "PandocError" [ operation Tostring $ defun "__tostring" - ### liftPure renderError + ### liftPure (\case + PandocLuaError e -> e + err -> renderError err) <#> udparam typePandocError "obj" "PandocError object" =#> functionResult pushText "string" "string representation of error." ]