@@ -240,15 +240,24 @@ local function load_global_config()
end
local content = f:read("*a")
f:close()
- local chunk = load("return " .. content, config_path, "t", {})
+ local chunk, err = load(content, config_path, "t", {})
if not chunk then
+ chunk, err = load("return " .. content, config_path, "t", {})
+ end
+ if not chunk then
+ io.stderr:write("warning: config syntax error in " .. config_path .. ": " .. err .. "\n")
return {}
end
local ok, result = pcall(chunk)
- if ok and type(result) == "table" then
- return result
+ if not ok then
+ io.stderr:write("warning: config execution error in " .. config_path .. ": " .. result .. "\n")
+ return {}
end
- return {}
+ if type(result) ~= "table" then
+ io.stderr:write("warning: config must return a table in " .. config_path .. "\n")
+ return {}
+ end
+ return result
end
---Load project config from <root>/.wt.lua
@@ -263,18 +272,24 @@ local function load_project_config(root)
local content = f:read("*a")
f:close()
- local chunk = load(content, config_path, "t", {})
+ local chunk, err = load(content, config_path, "t", {})
if not chunk then
- chunk = load("return " .. content, config_path, "t", {})
+ chunk, err = load("return " .. content, config_path, "t", {})
end
if not chunk then
+ io.stderr:write("warning: config syntax error in " .. config_path .. ": " .. err .. "\n")
return {}
end
local ok, result = pcall(chunk)
- if ok and type(result) == "table" then
- return result
+ if not ok then
+ io.stderr:write("warning: config execution error in " .. config_path .. ": " .. result .. "\n")
+ return {}
end
- return {}
+ if type(result) ~= "table" then
+ io.stderr:write("warning: config must return a table in " .. config_path .. "\n")
+ return {}
+ end
+ return result
end
---Split path into components