Skip to content

Commit

Permalink
Merge 5236775 into 19c863e
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed Jun 8, 2021
2 parents 19c863e + 5236775 commit 101fa31
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lua/pl/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ local link_attrib = lfs.symlinkattributes
local path = {}

local function err_func(name, param, err, code)
if code == nil then
return ("%s failed for '%s': %s"):format(tostring(name), tostring(param), tostring(err))
local ret = ("%s failed"):format(tostring(name))
if param ~= nil then
ret = ret .. (" for '%s'"):format(tostring(param))
end
return ("%s failed for '%s': %s (code %s)"):format(tostring(name), tostring(param), tostring(err), tostring(code))
ret = ret .. (": %s"):format(tostring(err))
if code ~= nil then
ret = ret .. (" (code %s)"):format(tostring(code))
end
return ret
end

--- Lua iterator over the entries of a given directory.
Expand Down Expand Up @@ -80,10 +85,10 @@ end
--- Get the working directory.
-- Implicit link to [`luafilesystem.currentdir`](https://keplerproject.github.io/luafilesystem/manual.html#reference)
-- @function currentdir
path.currentdir = function(d)
local ok, err, code = currentdir(d)
path.currentdir = function()
local ok, err, code = currentdir()
if not ok then
return ok, err_func("currentdir", d, err, code), code
return ok, err_func("currentdir", nil, err, code), code
end
return ok, err, code
end
Expand Down

0 comments on commit 101fa31

Please sign in to comment.