fix(profiling): ensure proper traces in case of require errors

This commit is contained in:
Folke Lemaitre 2023-10-09 23:42:05 +02:00
parent 5579d72576
commit 2782f8125e
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 6 additions and 1 deletions

View File

@ -10,8 +10,13 @@ local function profile_require()
if Util and not done[modname] then if Util and not done[modname] then
done[modname] = true done[modname] = true
Util.track({ require = modname }) Util.track({ require = modname })
local ret = vim.F.pack_len(r(modname)) local ok, ret = pcall(function()
return vim.F.pack_len(r(modname))
end)
Util.track() Util.track()
if not ok then
error(ret, 2)
end
return vim.F.unpack_len(ret) return vim.F.unpack_len(ret)
else else
return r(modname) return r(modname)