Skip to content

Commit

Permalink
fix(util): use xpcall in throttle for better stack traces
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent 4eab561 commit 6d9a0ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lua/trouble/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ function M.throttle(fn, opts)
executing = true
last = vim.loop.now()
vim.schedule(function()
local ok, err = pcall(fn, vim.F.unpack_len(args))
executing = false
if not ok then
xpcall(function()
fn(vim.F.unpack_len(args))
end, function(err)
vim.schedule(function()
error(err)
M.error(err)
end)
end
end)
executing = false
end)
end

Expand Down

0 comments on commit 6d9a0ba

Please sign in to comment.