From: Steven Barth Date: Sat, 30 Aug 2008 20:32:00 +0000 (+0000) Subject: libs/web: Return more verbose error messages when template execution fails X-Git-Tag: 0.8.0~234 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cec13fcb294a9146226a80766b798b392fa90ce9;p=oweals%2Fluci.git libs/web: Return more verbose error messages when template execution fails --- diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua index 907403fcb..d49bceac7 100644 --- a/libs/web/luasrc/template.lua +++ b/libs/web/luasrc/template.lua @@ -144,6 +144,7 @@ setmetatable(Template.cache, {__mode = "v"}) -- Constructor - Reads and compiles the template on-demand function Template.__init__(self, name) self.template = self.cache[name] + self.name = name -- Create a new namespace for this template self.viewns = {} @@ -226,7 +227,10 @@ function Template.render(self, scope) luci.util.updfenv(self.template, self.viewns) -- Now finally render the thing - self.template() + local stat, err = luci.util.copcall(self.template) + if not stat then + error("Error in template %s: %s" % {self.name, err}) + end -- Reset environment setfenv(self.template, oldfenv)