feat(lua): enable stack traces in error output (#16228)

This commit is contained in:
Gregory Anders
2021-11-06 08:26:10 -06:00
committed by GitHub
parent 1fdbd29dfa
commit 03b805aee6
13 changed files with 174 additions and 195 deletions

View File

@@ -155,12 +155,20 @@ function module.pcall_err_withfile(fn, ...)
return errmsg
end
function module.pcall_err(fn, ...)
function module.pcall_err_withtrace(fn, ...)
local errmsg = module.pcall_err_withfile(fn, ...)
return errmsg:gsub('.../helpers.lua:0: ', '')
end
function module.pcall_err(...)
return module.remove_trace(module.pcall_err_withtrace(...))
end
function module.remove_trace(s)
return (s:gsub("\n%s*stack traceback:.*", ""))
end
-- initial_path: directory to recurse into
-- re: include pattern (string)
-- exc_re: exclude pattern(s) (string or table)