refactor: replace vim.uv.* asserts with warn-and-bail

This commit is contained in:
2026-05-02 22:45:24 +02:00
parent 9568fc63a3
commit 8bd674622e
3 changed files with 32 additions and 8 deletions
+16 -5
View File
@@ -193,7 +193,11 @@ function M.watch()
return
end
watcher = assert(vim.uv.new_fs_event())
local w, err = vim.uv.new_fs_event()
if not w then
util.warning("pack: failed to create fs_event: %s", err)
return
end
local on_change, handle = util.keyed_debounce(
---@param filename string
function(filename)
@@ -210,16 +214,15 @@ function M.watch()
end,
200
)
on_change_handle = handle
assert(watcher:start(
local ok, err = w:start(
plugins_dir,
{},
---@param err string?
---@param filename string
function(err, filename)
if err then
log.error("Watch error: %s", err)
log.error("pack: watch error for %s: %s", filename, err)
return
end
if not filename or not filename:match("%.lua$") then
@@ -227,7 +230,15 @@ function M.watch()
end
on_change(filename)
end
))
)
if not ok then
util.warning("pack: failed to watch %s: %s", plugins_dir, err)
w:close()
handle:close()
return
end
on_change_handle = handle
watcher = w
end
function M.unwatch()