fix(pack): handle uv errors
This commit is contained in:
+16
-6
@@ -169,9 +169,12 @@ function M.watch()
|
|||||||
|
|
||||||
local plugins_dir = config_dir .. "/lua/plugins"
|
local plugins_dir = config_dir .. "/lua/plugins"
|
||||||
|
|
||||||
watcher = vim.uv.new_fs_event()
|
local err_msg, err_name
|
||||||
|
watcher, err_msg, err_name = vim.uv.new_fs_event()
|
||||||
if not watcher then
|
if not watcher then
|
||||||
log.error("Failed to create fs_event watcher")
|
log.error(
|
||||||
|
"Failed to create fs_event watcher (%s): %s", err_name, err_msg
|
||||||
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -188,12 +191,19 @@ function M.watch()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@type uv.uv_timer_t?
|
||||||
local timer = timers[filename]
|
local timer = timers[filename]
|
||||||
if timer ~= nil then
|
if not timer then
|
||||||
timer:stop()
|
timer, err_msg, err_name = vim.uv.new_timer()
|
||||||
else
|
if not timer then
|
||||||
timer = vim.uv.new_timer()
|
log.error(
|
||||||
|
"Failed to create new timer (%s): %s", err_name, err_msg
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
timers[filename] = timer
|
timers[filename] = timer
|
||||||
|
else
|
||||||
|
timer:stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
timer:start(
|
timer:start(
|
||||||
|
|||||||
Reference in New Issue
Block a user