Files
absolute-vim/lua/absolute/utils/safe-invoke.lua

16 lines
306 B
Lua

function SafeInvoke(func)
-- safely invoke a functions
-- if the function returns an error, return an empty string
-- otherwise return the result of the function
local ok, result = pcall(func)
if ok then
return result
else
return ""
end
end
return SafeInvoke