add better logging to modules
This commit is contained in:
@ -23,14 +23,13 @@ function modules:setup(speclist, overrides)
|
|||||||
|
|
||||||
-- loop through all modules and initialize them
|
-- loop through all modules and initialize them
|
||||||
for _, modpath in ipairs(speclist.modules) do
|
for _, modpath in ipairs(speclist.modules) do
|
||||||
local mod = module.new(
|
local mod = module.new(nil, modpath, speclist.modules.prefix, overrides)
|
||||||
nil,
|
if not mod then
|
||||||
modpath,
|
goto continue
|
||||||
speclist.modules.prefix,
|
end
|
||||||
overrides
|
|
||||||
)
|
|
||||||
|
|
||||||
table.insert(o.modules, mod)
|
table.insert(o.modules, mod)
|
||||||
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
local logger = require('dep.log')
|
||||||
local spec_man = require("dep.spec")
|
local spec_man = require("dep.spec")
|
||||||
local packager = require("dep.package")
|
local packager = require("dep.package")
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ function module:new(modpath, prefix, overrides)
|
|||||||
o.name = modpath
|
o.name = modpath
|
||||||
ok, o.mod = pcall(require, o.path)
|
ok, o.mod = pcall(require, o.path)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
logger:log("error", "failed to load module: %s", vim.inspect(o.mod))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -49,7 +51,8 @@ function module:new(modpath, prefix, overrides)
|
|||||||
|
|
||||||
ok, err = pcall(packager.register_speclist, o.mod, overrides)
|
ok, err = pcall(packager.register_speclist, o.mod, overrides)
|
||||||
if not ok then
|
if not ok then
|
||||||
error(string.format("%s <- %s", err, o.name))
|
logger:log("error", "%s <- %s", err, o.name)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
Reference in New Issue
Block a user