Skip to content

Commit

Permalink
style(tools/module): improve code style for readability (#12798)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Mar 29, 2024
1 parent 8fe1409 commit 6f3c0da
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kong/tools/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ local _M = {}
-- @return success A boolean indicating whether the module was found.
-- @return module The retrieved module, or the error in case of a failure
function _M.load_module_if_exists(module_name)
local status, res = xpcall(function()
return require(module_name)
end, debug.traceback)
local status, res = xpcall(require, debug.traceback, module_name)

if status then
return true, res
end

-- Here we match any character because if a module has a dash '-' in its name, we would need to escape it.
elseif type(res) == "string" and find(res, "module '" .. module_name .. "' not found", nil, true) then
if type(res) == "string" and find(res, "module '" .. module_name .. "' not found", nil, true) then
return false, res
else
error("error loading module '" .. module_name .. "':\n" .. res)
end

error("error loading module '" .. module_name .. "':\n" .. res)
end


Expand Down

1 comment on commit 6f3c0da

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:6f3c0da512efdd3d0b3437710d0e031e9dcd1d55
Artifacts available https://github.com/Kong/kong/actions/runs/8475917003

Please sign in to comment.