@@ -42,6 +42,7 @@ import Text.Pandoc.UTF8 (fromString, toString)
4242import Data.ByteString (ByteString)
4343import qualified Data.ByteString.Char8 as C8
4444import Data.Monoid
45+import Control.Monad (when)
4546import qualified Data.Map as M
4647import Text.Pandoc.Templates
4748
@@ -151,7 +152,11 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do
151152 luaScript <- C8.unpack `fmap` C8.readFile luaFile
152153 lua <- Lua.newstate
153154 Lua.openlibs lua
154− Lua.loadstring lua luaScript "custom"
155+ status <- Lua.loadstring lua luaScript luaFile
156+ -- check for error in lua script (later we'll change the return type
157+ -- to handle this more gracefully):
158+ when (status /= 0) $
159+ Lua.tostring lua 1 >>= error
155160 Lua.call lua 0 0
156161 -- TODO - call hierarchicalize, so we have that info
157162 rendered <- docToCustom lua opts doc