use xpcall and get backtrace

This commit is contained in:
leaf corcoran 2014-02-15 14:07:36 -08:00
parent df340f7104
commit da1bc6f8ec

View File

@ -616,13 +616,17 @@ local build_grammar = wrap_env(function()
end
local tree
local pass, err = pcall(function(...)
tree = self._g:match(str, ...)
end, ...)
local parse_args = {...}
local pass, err = xpcall(function()
tree = self._g:match(str, unpack(parse_args))
end, function(err)
return debug.traceback(err, 2)
end)
-- regular error, let it bubble up
if type(err) == "string" then
error(err)
return nil, err
end
if not tree then