aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-10-05 21:49:33 +0200
committerAlbert Krewinkel <[email protected]>2022-10-05 21:53:03 +0200
commit48ab7a17cf14588f36c601bf9aca2f74e801f2a9 (patch)
tree65639d7bd9ca1ffed0e3d646a84f509708afcff1 /pandoc-lua-engine
parentb05c380f6ff4375cbc27955653fd31310ff2f94d (diff)
Lua: produce more informative error messages for pandoc errors
Errors are reported in Lua in the same words in which they would be reported in the terminal.
Diffstat (limited to 'pandoc-lua-engine')
-rw-r--r--pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs8
-rw-r--r--pandoc-lua-engine/test/lua/module/pandoc-template.lua2
2 files changed, 5 insertions, 5 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 7f83f2fc0..7feba2d45 100644
--- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs
+++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/PandocError.hs
@@ -19,9 +19,9 @@ module Text.Pandoc.Lua.Marshal.PandocError
)
where
-import HsLua (LuaError, Peeker, Pusher, liftLua, pushString)
+import HsLua (LuaError, Peeker, Pusher, liftLua, pushText)
import HsLua.Packaging
-import Text.Pandoc.Error (PandocError (PandocLuaError))
+import Text.Pandoc.Error (PandocError (PandocLuaError), renderError)
import qualified HsLua as Lua
import qualified Text.Pandoc.UTF8 as UTF8
@@ -30,9 +30,9 @@ import qualified Text.Pandoc.UTF8 as UTF8
typePandocError :: LuaError e => DocumentedType e PandocError
typePandocError = deftype "PandocError"
[ operation Tostring $ defun "__tostring"
- ### liftPure (show @PandocError)
+ ### liftPure renderError
<#> udparam typePandocError "obj" "PandocError object"
- =#> functionResult pushString "string" "string representation of error."
+ =#> functionResult pushText "string" "string representation of error."
]
mempty -- no members
diff --git a/pandoc-lua-engine/test/lua/module/pandoc-template.lua b/pandoc-lua-engine/test/lua/module/pandoc-template.lua
index c288b2016..638b31f09 100644
--- a/pandoc-lua-engine/test/lua/module/pandoc-template.lua
+++ b/pandoc-lua-engine/test/lua/module/pandoc-template.lua
@@ -50,7 +50,7 @@ return {
test('fails if template has non-existing partial', function ()
assert.error_matches(
function () return template.compile('${ nosuchpartial() }') end,
- 'PandocCouldNotFindDataFileError'
+ 'Could not find data file templates/nosuchpartial'
)
end),
test('works with default template that uses partials', function ()