Module:Data: Difference between revisions
Make this work when called with wikitext's fake tables
>Jackmcbarn (Improve error messages) |
mp>Jackmcbarn (Make this work when called with wikitext's fake tables) |
||
Line 8: | Line 8: | ||
local ty = type(data) | local ty = type(data) | ||
if ty ~= 'table' then | if ty ~= 'table' then | ||
local args = {} | |||
for j = 1, i - 1 do | |||
args[j] = frame.args[j] | |||
end | |||
if frame.args.softfail then | if frame.args.softfail then | ||
return '<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat( | return '<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat(args, '.')) .. ', which is a ' .. ty .. '</span>' | ||
else | else | ||
error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat( | error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat(args, '.') .. ', which is a ' .. ty) | ||
end | end | ||
end | end |