Jump to content

Module:Transclusion count: Difference between revisions

wrap mw.loadData in pcall
m (1 revision imported)
en>Ahecht
(wrap mw.loadData in pcall)
Line 21: Line 21:
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
template =  mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local index = mw.ustring.sub(mw.title.new(template).text,1,1)
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))
local status, data = pcall(function ()
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")))  
end)
if status then
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
end
end
end
end
end
Anonymous user