From 0ed14a40d9799ac8d92aaf9eb1cd9be22ffd6b14 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Mon, 23 Dec 2024 22:44:13 +0200 Subject: [PATCH] fix(iferr): improve error handling (#75) --- lua/gopher/iferr.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/gopher/iferr.lua b/lua/gopher/iferr.lua index a1cdf9f..bcd4b24 100644 --- a/lua/gopher/iferr.lua +++ b/lua/gopher/iferr.lua @@ -14,8 +14,14 @@ function iferr.iferr() local data = vim.fn.systemlist((c.commands.iferr .. " -pos " .. boff), vim.fn.bufnr "%") if vim.v.shell_error ~= 0 then - error("iferr failed: " .. data) - log.error("failed. output: " .. data) + if string.find(data[1], "no functions at") then + vim.print "no function found" + log.warn("iferr: no function at " .. boff) + return + end + + log.error("failed. output: " .. vim.inspect(data)) + error("iferr failed: " .. vim.inspect(data)) end vim.fn.append(pos, data)