X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Ftemplate.lua;h=962c2ea8863809ebe688006d3f451880e73e8ada;hb=cb45e870f852362cc4b2c839ab909b01de606398;hp=80a3206af59b0c1dc15b0e0df1bbf10844b7dc64;hpb=bb91ef614a1a80a59389694ae1ffe1699cb9b90c;p=project%2Fluci.git diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua index 80a3206af..962c2ea88 100644 --- a/libs/web/luasrc/template.lua +++ b/libs/web/luasrc/template.lua @@ -78,7 +78,10 @@ function Template.__init__(self, name) -- If we have no valid template throw error, otherwise cache the template if not self.template then - error(err) + error("Failed to load template '" .. name .. "'.\n" .. + "Error while parsing template '" .. sourcefile .. "'.\n" .. + "A syntax error occured near '" .. + (err or "(nil)"):gsub("\t", "\\t"):gsub("\n", "\\n") .. "'.") else self.cache[name] = self.template end @@ -99,6 +102,7 @@ function Template.render(self, scope) -- Now finally render the thing local stat, err = util.copcall(self.template) if not stat then - error("Error in template %s: %s" % {self.name, err}) + error("Failed to execute template '" .. self.name .. "'.\n" .. + "A runtime error occured: " .. tostring(err or "(nil)")) end end